/// <summary> /// 二进制消息 /// </summary> void OnBinaryMessage(ClientSession session, ByteBuffer buffer) { string str = buffer.ReadString(); session.uid = buffer.ReadInt(); ByteBuffer newBuffer = new ByteBuffer(); newBuffer.WriteByte((byte)ProtocalType.BINARY); newBuffer.WriteString(str); SocketUtil.SendMessage(session, Protocal.Login, newBuffer); UserUtil.Add(session.uid, session); Console.WriteLine("OnBinaryMessage--->>>" + str + session.uid); }
public void OnMessage(ClientSession session, ByteBuffer buffer) { string str = buffer.ReadString(); int uid = buffer.ReadInt(); ushort commandId = (ushort)Protocal.Login; ByteBuffer newBuffer = new ByteBuffer(); newBuffer.WriteShort(commandId); newBuffer.WriteByte(1); newBuffer.WriteString(str); SocketUtil.SendMessage(session, newBuffer); session.uid = uid; UserUtil.Add(uid, session); Console.WriteLine("OnMessage--->>>" + str + uid); }
public void OnDBTask(MySqlConnection conn, CustomArgs args) { string token = args.GetParam("token") as string; ClientSession session = args.GetParam("session") as ClientSession; DBBase.DBStoredProcedCmd cmd = new DBBase.DBStoredProcedCmd("PRO_CHECK_LOGIN", conn); cmd.AddParamVChar("token", token, token.Length); int bSuc = cmd.Execute(); if (bSuc == 0) { string account = cmd.GetValue(0, "account") as string; int nGold = (int)cmd.GetValue(0, "gold"); ByteBuffer buffer = new ByteBuffer(); buffer.WriteString(account); buffer.WriteInt(nGold); UserUtil.Add(session.uid, session); SocketUtil.SendMessage(session, Protocal.Login, buffer); return; } }