protected Common(LowWrapperTransport transport)
        {
            channels = transport.Channels;

            deadSockets = new List <string>();

            AddNotifyPeerConnectionRequestOptions addNotifyPeerConnectionRequestOptions = new AddNotifyPeerConnectionRequestOptions();

            addNotifyPeerConnectionRequestOptions.LocalUserId = EOSSDKComponent.LocalUserProductId;
            addNotifyPeerConnectionRequestOptions.SocketId    = null;

            OnIncomingConnectionRequest += OnNewConnection;
            OnRemoteConnectionClosed    += OnConnectFail;

            incomingNotificationId = EOSSDKComponent.GetP2PInterface().AddNotifyPeerConnectionRequest(addNotifyPeerConnectionRequestOptions,
                                                                                                      null, OnIncomingConnectionRequest);

            AddNotifyPeerConnectionClosedOptions addNotifyPeerConnectionClosedOptions = new AddNotifyPeerConnectionClosedOptions();

            addNotifyPeerConnectionClosedOptions.LocalUserId = EOSSDKComponent.LocalUserProductId;
            addNotifyPeerConnectionClosedOptions.SocketId    = null;

            outgoingNotificationId = EOSSDKComponent.GetP2PInterface().AddNotifyPeerConnectionClosed(addNotifyPeerConnectionClosedOptions,
                                                                                                     null, OnRemoteConnectionClosed);

            if (outgoingNotificationId == 0 || incomingNotificationId == 0)
            {
                Debug.LogError("Couldn't bind notifications with P2P interface");
            }

            incomingPackets = new Dictionary <PacketKey, List <List <Packet> > >();

            this.transport = transport;
        }
 private Server(LowWrapperTransport transport, int maxConnections) : base(transport)
 {
     this.maxConnections = maxConnections;
     epicToMirrorIds     = new BidirectionalDictionary <ProductUserId, ulong>();
     epicToSocketIds     = new Dictionary <ProductUserId, SocketId>();
     nextConnectionID    = 1;
 }
Beispiel #3
0
        public override void Init()
        {
            instance = this;
            Debug.Assert(IsSupported, "This platform is not supported by current transport");

            //OnClientConnected += OnClientConnect;
            //OnClientDisconnected += OnClientDisconnect;
            //OnClientDataReceived += OnClientDataRecv;
            //OnClientError += OnClientException;

            ///OnServerConnected += OnServerConnect;
            ///OnServerDisconnected += OnServerDisconnect;
            ///OnServerDataReceived += OnServerDataRecv;
            ///OnServerError += OnServerException;

            OnCommonConnected    += OnCommonConnect;
            OnCommonDisconnected += OnCommonDisconnect;
            OnCommonDataReceived += OnCommonDataRecv;
            OnCommonErrored      += OnCommonException;

            int count = MLAPI_CHANNELS.Length;

            Channels = new PacketReliability[count];

            for (int i = 0; i < count; i++)
            {
                Channels[i] = ConvertNetworkDelivery(MLAPI_CHANNELS[i].Delivery);
            }
        }
Beispiel #4
0
        public static Client CreateClient(LowWrapperTransport transport, string host)
        {
            Client c = new Client(transport);

            c.hostAddress = host;
            c.socketId    = new SocketId()
            {
                SocketName = RandomString.Generate(20)
            };

            //c.OnConnected += () => transport.OnClientConnected.Invoke();
            //c.OnDisconnected += () => transport.OnClientDisconnected.Invoke();
            //c.OnReceivedData += (data, channel) => transport.OnClientDataReceived.Invoke(data, channel);
            //c.OnReceivedData += (data, channel) => transport.OnClientDataReceived.Invoke(new ArraySegment<byte>(data), channel);

            return(c);
        }
        public static Server CreateServer(LowWrapperTransport transport, int maxConnections)
        {
            Server s = new Server(transport, maxConnections);

            //s.OnConnected += (id) => transport.OnServerConnected.Invoke(id);
            //s.OnDisconnected += (id) => transport.OnServerDisconnected.Invoke(id);
            //s.OnReceivedData += (id, data, channel) => transport.OnServerDataReceived.Invoke(id, data, channel);
            //s.OnReceivedData += (id, data, channel) => transport.OnServerDataReceived.Invoke(id, new ArraySegment<byte>(data), channel);
            //s.OnReceivedError += (id, exception) => transport.OnServerError.Invoke(id, exception);

            if (!EOSSDKComponent.Initialized)
            {
                Debug.LogError("EOS not initialized.");
            }

            return(s);
        }
Beispiel #6
0
 private Client(LowWrapperTransport transport) : base(transport)
 {
     ConnectionTimeout = TimeSpan.FromSeconds(Math.Max(1, transport.timeout));
 }