//私聊 public void do2002(MessageNode node) { User user = node.socket.user; ByteBuffer buffer = node.buffer; GameHall.shareGameHall().SiLiaoMessage(user, buffer); }
//房间密码设置 public void do7017(MessageNode node) { User user = node.socket.user; ByteBuffer buffer = node.buffer; GameHall.shareGameHall().setRoomPassword(buffer.readInt(), user, buffer.readString()); }
//玩家加入房间 public void do6310(MessageNode node) { User user = node.socket.user; ByteBuffer buffer = node.buffer; GameHall.shareGameHall().addRoom(buffer.readInt(), user, buffer.readString()); }
public void SendRoomState() { int type = this.State == RoomState.Ring ? 1 : -1; if (this.State == RoomState.Adding) { type = 0; } ByteBuffer buffer = ByteBuffer.CreateByteBufferType(Protcol.房间状态);//7005 buffer.writeInt(this.Roomid); buffer.writeInt(type); GameHall.shareGameHall().sendAllMessage(buffer); }
//用户登陆 public void do1001(MessageNode node) { ClientNode client = node.socket; ByteBuffer buffer = node.buffer; string name = buffer.readString(); if (g.ContansUser(name)) { client.send(ConstomMessage.getError("该用户已在别处登陆,服务器拒绝登陆!")); return; } if (!FFactory.Exists(Share.USER_SAVE_PATH + name)) { client.send(ConstomMessage.getError("用户名错误!")); return; } User user = FFactory.ReadObject <User>(Share.USER_SAVE_PATH + name); string pwd = buffer.readString(); if (!user.Password.Equals(pwd)) { client.send(ConstomMessage.getError("密码错误!")); } else { user.BindSocket(client); g.addUser(user); ByteBuffer buf = new ByteBuffer(); buf.writeInt(Protcol.用户登陆); buf.writeString(user.UserName); buf.writeString(user.ChinaName); //debug.logln(user.Money, user.Duanwei, user.Image, user.Text); buf.writeInt(user.Money); buf.writeString(user.Duanwei); buf.writeString(user.Image); buf.writeString(user.Text); client.send(buf); GameHall.shareGameHall().addGameHall(user); //debug.logln(user.ChinaName + " 登陆成功"); //user.ReadImageBuffer();//先把图片读出来 } }
public void ClentExit() { if (this.user != null) { user.connected = 0; UserGroup.ShareUserGroup().RemoveUser(this.user.UserName); GameHall.shareGameHall().UserExitGameHall(user); debug.logln(this.user.ChinaName + " > 离开了服务器"); this.user = null; } if (this.buffer != null) { this.buffer.Clear(); this.buffer = null; } }
public void ExitRoom(User user) { if (user.Ready > 0) { this.readyCount--; } user.Ready = -1; setDesk(user, false); this.State = RoomState.Adding; base.Remove(user); updateRoomOwner(user); //如果正在游戏中,提前gameOver if (this.State == RoomState.Ring) { this.GameOver(); } this.ExitUserByteBuffer(user);//7999 this.game.Clear(); GameHall.shareGameHall().UpdateRoomInfomation(user, -1); user.room = null; this.SendRoomState(); }