Exemplo n.º 1
0
 public void Init(enProtocolType type, int port)
 {
     gateWay = new GateWay();
     gateWay.Init(type, port, this);
     rpcManager = new RPCManager();
     rpcManager.Init();
 }
Exemplo n.º 2
0
 public void Init(enProtocolType type, int port, ISessionListener listener)
 {
     this.port       = port;
     sessionListener = listener;
     protocolType    = type;
     sessions        = new Dictionary <uint, ISession>();
     isRunning       = true;
     if (protocolType == enProtocolType.KCP)
     {
         currentSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
         currentSocket.Bind(new IPEndPoint(IPAddress.Any, this.port));
         threadRecv = new Thread(ThreadRecv)
         {
             IsBackground = true
         };
         threadRecv.Start();
     }
     else if (protocolType == enProtocolType.TCP)
     {
         currentSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);;
         currentSocket.Bind(new IPEndPoint(IPAddress.Any, this.port));
         currentSocket.Listen(10);
         StartAccept(null);
     }
 }
Exemplo n.º 3
0
 public void Init(enProtocolType protocolType, int connID, int bindPort)
 {
     Debuger.Log("connId:{0}, bindPort:{1}", connID, bindPort);
     ntfHelpers = new Dictionary <uint, ListenerHelper>();
     rspHelpers = new Dictionary <uint, ListenerHelper>();
     if (protocolType == enProtocolType.KCP)
     {
         connection = new KCPConnection();
     }
     else if (protocolType == enProtocolType.TCP)
     {
         connection = new TCPConnection();
     }
     connection.Init(connID, bindPort);
     rpcManager = new RPCManager();
     rpcManager.Init();
 }