Esempio n. 1
0
        public INetConnector GetConnector(int uid)
        {
            INetConnector ret = null;

            mConnectorMap.TryGetValue(uid, out ret);

            return(ret);
        }
Esempio n. 2
0
        public void RegisterConnector(int uid, ConnectionType type, IPacketFormat pf, IPacketHandlerManager phm, Callback <bool> connected, Callback <int, Byte[]> recieved, Callback disconnected, Callback error)
        {
            INetConnector ctor = null;

            switch (type)
            {
            case ConnectionType.TCP: ctor = new TCPConnector(pf, phm); break;
            //case ConnectionType.UDP: ctor = new UDPConnector(pf, phm); break;
            //case ConnectionType.WEBSOCKET: ctor = new WebSocketConnector(pf, phm); break;

            default: ctor = new TCPConnector(pf, phm); break;
            }

            ctor.OnConnected    = connected;
            ctor.OnRecieved     = recieved;
            ctor.OnDisconnected = disconnected;
            ctor.OnError        = error;
            ctor.SetUid(uid);

            mConnectorMap.Add(uid, ctor);
        }