using CommonServer_ICE.Msg; using Slice; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CommonServer_ICE.handler { /// /// 服务器端TCP数据接收器实现类:接收客户端发来的ICE请求,委托监听器实现类处理 /// internal class ServerTcpSendHandler : SenderDisp_ { // 委托处理 private ServerMsgHandler delegateHandler; public ServerTcpSendHandler(ServerMsgHandler delegateHandler) { this.delegateHandler = delegateHandler; } /// /// 接收客户端发送的数据包 /// /// 发送方侦听端口 /// 数据包 /// Ice通讯包 public override void SendData(int recvPort, TransMessage message, Ice.Current current) { Ice.TCPConnectionInfo tcpConInfo = (Ice.TCPConnectionInfo)current.con.getInfo(); delegateHandler.RecvData(recvPort, message, tcpConInfo.remoteAddress, tcpConInfo.remotePort); } /// /// 接收客户端收到服务器数据包时回送的应答数据包序列号 /// /// 发送方侦听端口 /// 应答数据包序列号 /// Ice通讯包 public override void SendAck(int recvPort, long serial, Ice.Current current) { Ice.TCPConnectionInfo tcpConInfo = (Ice.TCPConnectionInfo)current.con.getInfo(); delegateHandler.SendDataRecvAck(recvPort, serial, tcpConInfo.remoteAddress, tcpConInfo.remotePort); } /// /// 客户端连接到服务器 /// /// 发送方侦听端口 /// Ice通讯包 public override void Connect(int recvPort, Ice.Current current) { Ice.TCPConnectionInfo tcpConInfo = (Ice.TCPConnectionInfo)current.con.getInfo(); delegateHandler.Connect(recvPort, tcpConInfo.remoteAddress, tcpConInfo.remotePort); } /// /// 服务器连接到客户端的正确连接响应 /// /// Ice通讯包> public override void ConnectAck(Ice.Current current) { // 目前服务器端不连接到客户端,所以不处理此请求 } /// /// 服务器端收到客户端发来的关闭连接请求 /// /// 发送方侦听端口 /// Ice通讯包 public override void Close(int recvPort, Ice.Current current) { Ice.TCPConnectionInfo tcpConInfo = (Ice.TCPConnectionInfo)current.con.getInfo(); delegateHandler.Close(recvPort, tcpConInfo.remoteAddress, tcpConInfo.remotePort); } /// /// 服务器端收到客户端接到服务器端的关闭请求后的确认请求 /// /// 发送方侦听端口 /// Ice通讯包 public override void CloseAck(int recvPort, Ice.Current current) { Ice.TCPConnectionInfo tcpConInfo = (Ice.TCPConnectionInfo)current.con.getInfo(); delegateHandler.CloseAck(recvPort, tcpConInfo.remoteAddress, tcpConInfo.remotePort); } } }