add socket connection
This commit is contained in:
parent
1de440cedb
commit
9787a9d468
9 changed files with 7302 additions and 9 deletions
|
@ -1,14 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
const socketio = require('socket.io');
|
||||
const GameNet = require('./net');
|
||||
|
||||
class GameServer {
|
||||
constructor() {
|
||||
|
||||
constructor(webServer) {
|
||||
this.net = new GameNet();
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
this.net.listen();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
9
server/game/net/connection.js
Normal file
9
server/game/net/connection.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
class Connection {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Connection;
|
0
server/game/net/events.js
Normal file
0
server/game/net/events.js
Normal file
25
server/game/net/index.js
Normal file
25
server/game/net/index.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
'use strict';
|
||||
|
||||
const socketio = require('socket.io');
|
||||
|
||||
const Connection = require('./connection.js');
|
||||
|
||||
class GameNet {
|
||||
constructor() {
|
||||
this.io = socketio(starbugs.webServer.appServer);
|
||||
}
|
||||
|
||||
listen() {
|
||||
let io = this.io;
|
||||
|
||||
this.io.on('connection', socket => {
|
||||
console.log('connection');
|
||||
|
||||
socket.on('other event', data => {
|
||||
console.log(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GameNet;
|
0
server/game/room/index.js
Normal file
0
server/game/room/index.js
Normal file
Loading…
Add table
Add a link
Reference in a new issue