public override void Parse(UserClient user, byte moduleCode, byte operationCode, OperationRequest operationRequest, SendParameters sendParameters) { ServerItemVo currentServer = new ServerItemVo(); currentServer.id = 1; currentServer.title = "天府情缘"; currentServer.host = "192.168.1.35:4531"; currentServer.status = 2; S2CMessage msg = new S2CMessage((byte)moduleCode, (byte)operationCode); msg.Add(1, JsonMapper.ToJson(currentServer)); OperationResponse response = new OperationResponse((byte)moduleCode, msg); user.SendOperationResponse(response, sendParameters); Global.Info("获取当前服务器列表"); }
public override void Parse(UserClient user, byte moduleCode, byte operationCode, OperationRequest operationRequest, SendParameters sendParameters) { //获取用户名和密码 string username = operationRequest.Parameters[(byte)1].ToString(); string userpwd = operationRequest.Parameters[(byte)2].ToString(); AccountAction aa = new AccountAction(); Account ac = aa.CheckLogin(username, userpwd); //构建消息 S2CMessage msg = new S2CMessage((byte)Module.Login, (byte)LoginOperation.UserLogin); Global.Info("向客户端发送信息" + msg.moudleCode + "," + msg.operationCode); LoginResultVo lro = new LoginResultVo(); //登录成功 if (ac != null) { lro.result = 1; lro.info = "登录成功"; } else { lro.result = 0; lro.info = "用户名或密码错误!"; } msg.Add((byte)1, JsonMapper.ToJson(lro)); //发送反馈 OperationResponse response = new OperationResponse((byte)moduleCode, msg); user.SendOperationResponse(response, sendParameters); }
public override void Parse(UserClient user, byte moduleCode, byte operationCode, OperationRequest operationRequest, SendParameters sendParameters) { //构建消息 S2CMessage msg = new S2CMessage((byte)Module.ServerList, (byte)ServerListOperation.FetchAllServer); //读取配置文件 string json = File.ReadAllText(Global.AppRootFolder + "\\serverlist.json"); ServerListVo svrinfo = JsonMapper.ToObject <ServerListVo>(json); //随机服务器状态 foreach (ServerItemVo item in svrinfo.servers) { item.status = new Random().Next(1, 3); } //添加到发送字典 msg.Add(1, JsonMapper.ToJson(svrinfo)); //发送反馈 OperationResponse response = new OperationResponse((byte)moduleCode, msg); user.SendOperationResponse(response, sendParameters); Global.Info("收到客户端消息" + moduleCode + "," + operationCode); }