public PackageLookup( IPackageRedirector packageRedirector, IPackageProtocol[] packageProtocols) { _packageRedirector = packageRedirector; _packageProtocols = packageProtocols; }
//public SocketClient(string hostIp, int hostPort) : this(hostIp, hostPort, new SocketPackageProtocol()) { } /// <summary> /// /// </summary> /// <param name="hostIp">远程IP</param> /// <param name="hostPort">远程端口号</param> /// <param name="protocol">包协议类型</param> /// <param name="protocolType">Socket支持的类型</param> /// <param name="packageSize">包大小</param> public SocketClient(string hostIp, int hostPort, IPackageProtocol <T> protocol, ProtocolType protocolType = ProtocolType.Tcp, int packageSize = 1024 *1024) { if (Client != null && Client.Connected) { Client.Shutdown(SocketShutdown.Both); System.Threading.Thread.Sleep(10); Client.Close(); } m_packageSize = packageSize; this.protocol = protocol; SocketFactory sf = new SocketFactory(); //sf.SetupReceiveEvent += OnSetupReceiveEvent; Client = sf.Get(hostIp, hostPort, protocolType); }
// public SocketClient<T>(Socket socket) :this<T>(socket,new SocketPackageProtocol()) { } /// <summary> /// /// </summary> /// <param name="socket">要绑定的Socket对象</param> /// <param name="protocol">包协议类型</param> /// <param name="packageSize">包大小</param> public SocketClient(Socket socket, IPackageProtocol <T> protocol, int packageSize = 1024 *1024) { if (Client != null && Client.Connected) { Client.Shutdown(SocketShutdown.Both); System.Threading.Thread.Sleep(10); Client.Close(); } m_packageSize = packageSize; this.protocol = protocol; Client = socket; T ssi = new T(); ssi.Body = new byte[packageSize]; OnSetupReceiveEvent(this, ssi); }
public TcpSocketClient(string serverIP, int serverPort, IPackageProtocol <T> protocol, int packageSize = 1024 *1024) : base(serverIP, serverPort, protocol, ProtocolType.Tcp, packageSize) { }
public UdpSocketClient(IPackageProtocol <T> protocol, int packageSize = 1024 *1024) : base("127.0.0.1", 0, protocol, ProtocolType.Udp, packageSize) { }
public TcpClient(string serverIp, int serverPort, ProtocolTypes protocolType, Encoding encoding, IPackageProtocol <ScoketPackage> protocol) : base(serverIp, serverPort, protocolType, encoding, protocol) { }