public void DoReady(Conn client, byte[] buffer) { var simpleInt = NetUtil.ProtobufDeserialize <simpledata.SimpleInt>(buffer); int roomid = simpleInt.simple; NiuNiuGame game = nnGames[roomid]; game.PlayerReady(client); }
public void DoLeave(Conn client, byte[] buffer) { var simpleInt = NetUtil.ProtobufDeserialize <simpledata.SimpleInt>(buffer); int roomid = simpleInt.simple; NiuNiuGame nngame = nnGames[roomid]; if (nngame.RoomLeave(client)) { nnGames.Remove(roomid); LogUtil.LogInfo("****** 房间解散 :" + roomid); } }
public void DoCreate(Conn client, byte[] buffer) { int roomid = new Random().Next(1000, 10000); while (nnGames.ContainsKey(roomid)) { roomid = new Random().Next(1000, 10000); } var newGame = new NiuNiuGame(roomid); newGame.RoomCreate(client); nnGames.Add(roomid, newGame); LogUtil.LogInfo("****** 创建房间 :" + roomid); }
public void DoJion(Conn client, byte[] buffer) { var simpleInt = NetUtil.ProtobufDeserialize <simpledata.SimpleInt>(buffer); int jroomid = simpleInt.simple; if (!nnGames.ContainsKey(jroomid)) { var simpleStr = new simpledata.SimpleString(); simpleStr.simple = string.Format("加入房间失败:房间号{0}不存在!", jroomid); byte[] data = NetUtil.ProtobufSerialize(simpleStr); client.SendAsync((ushort)MainID.NiuNiu, (ushort)NiuNiuID.JionFailure, data); return; } NiuNiuGame jGame = nnGames[jroomid]; jGame.RoomJion(client); }