void OnRead(TcpSocketClient client, byte[] buffers) { ThreadCalls(() => { try { BaseCommand cmd = new BaseCommand(buffers); switch (cmd.Command) { case Commands.Bind: var bind = new Bind(buffers); this.BindHandler(client, bind); break; case Commands.UnBind: var unbind = new UnBind(buffers); this.UnBindHandler(client, unbind); break; case Commands.Submit: var submit = new Submit(buffers); this.SubmitHandler(client, submit); PrintLog("接收到 \"" + submit.SPNumber + "\" 发送送给 \"" + submit.UserNumber + "\" 的消息: " + submit.MessageContent); break; case Commands.Deliver_Resp: this.DeliverRespHandler(client, new Deliver_Resp(buffers)); break; case Commands.Report_Resp: this.ReportRespHandler(client, new Report_Resp(buffers)); break; default: break; } PrintLog("接收到一条 \"" + client.LocalIPAddress + "\" 发送的命令:" + Commands.GetString(cmd.Command)); } catch (Exception e) { if (e is BadCmdHeadException) { PrintLog(client.LocalIPAddress + " 发送错误的消息头格式!"); } else if (e is BadCmdBodyException) { PrintLog(client.LocalIPAddress + " 发送错误的消息体格式!"); } else { PrintLog("接受 \"" + client.LocalIPAddress + "\" 发送的消息出现错误:" + e.Message); } //断开连接 client.Disconnect(); } }); }
void UnBindHandler(TcpSocketClient client, UnBind ubind) { var resp = new UnBind_Resp() { SequenceNumber = ubind.SequenceNumber }; client.Send(resp.GetBytes()); }
public override int ProcessUnBindRequest(UnBind rpc) { if (rpc.Argument.LinkSids.Count == 0) { UnBindModules(rpc.Sender, rpc.Argument.Modules.Keys); } else { // 动态绑定 foreach (var linkSid in rpc.Argument.LinkSids) { var link = App.Instance.LinkdService.GetSocket(linkSid); if (null != link) { var linkSession = link.UserState as LinkSession; linkSession.UnBind(link, rpc.Argument.Modules.Keys, rpc.Sender); } } } rpc.SendResultCode(BBind.ResultSuccess); return(Zeze.Transaction.Procedure.Success); }
private void UnBind() { UnBind vUnBindBll = new UnBind(); vUnBindBll.Write(_Socket); UnBindResp vResp = (UnBindResp)vUnBindBll.Read(_Socket); if (vResp._Header.CommandId.Equals(SGIPCommandDefine.SGIP_UNBIND_RESP)) { try { if (_Socket != null) { _Socket.Close(); } } catch (IOException e) { throw e; } } }
private void client_evUnBind(object sender, UnBind data) { _log.Info("UnBind request received"); }