Esempio n. 1
0
        protected void Dispose()
        {
            EOSSDKComponent.GetP2PInterface().RemoveNotifyPeerConnectionRequest(incomingNotificationId);
            EOSSDKComponent.GetP2PInterface().RemoveNotifyPeerConnectionClosed(outgoingNotificationId);

            transport.ResetIgnoreMessagesAtStartUpTimer();
        }
Esempio n. 2
0
        protected Common(EosTransport transport)
        {
            channels = transport.Channels;

            AddNotifyPeerConnectionRequestOptions addNotifyPeerConnectionRequestOptions = new AddNotifyPeerConnectionRequestOptions();

            addNotifyPeerConnectionRequestOptions.LocalUserId = EOSSDKComponent.LocalUserProductId;
            SocketId socketId = new SocketId();

            socketId.SocketName = SOCKET_ID;
            addNotifyPeerConnectionRequestOptions.SocketId = socketId;

            OnIncomingConnectionRequest += OnNewConnection;
            OnRemoteConnectionClosed    += OnConnectFail;

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

            AddNotifyPeerConnectionClosedOptions addNotifyPeerConnectionClosedOptions = new AddNotifyPeerConnectionClosedOptions();

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

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

            this.transport = transport;
        }
Esempio n. 3
0
        protected Common(EosTransport 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");
            }

            this.transport = transport;
        }
Esempio n. 4
0
        protected override void OnNewConnection(OnIncomingConnectionRequestInfo result)
        {
            if (ignoreAllMessages)
            {
                return;
            }

            if (deadSockets.Contains(result.SocketId.SocketName))
            {
                Debug.LogError("Received incoming connection request from dead socket");
                return;
            }

            if (hostProductId == result.RemoteUserId)
            {
                EOSSDKComponent.GetP2PInterface().AcceptConnection(
                    new AcceptConnectionOptions()
                {
                    LocalUserId  = EOSSDKComponent.LocalUserProductId,
                    RemoteUserId = result.RemoteUserId,
                    SocketId     = result.SocketId
                });
            }
            else
            {
                Debug.LogError("P2P Acceptance Request from unknown host ID.");
            }
        }
Esempio n. 5
0
 protected void CloseP2PSessionWithUser(ProductUserId clientUserID) => EOSSDKComponent.GetP2PInterface().CloseConnection(
     new CloseConnectionOptions()
 {
     LocalUserId  = EOSSDKComponent.LocalUserProductId,
     RemoteUserId = clientUserID,
     SocketId     = new SocketId()
     {
         SocketName = SOCKET_ID
     }
 });
Esempio n. 6
0
 protected void Send(ProductUserId host, SocketId socketId, byte[] msgBuffer, byte channel) =>
 EOSSDKComponent.GetP2PInterface().SendPacket(new SendPacketOptions()
 {
     AllowDelayedDelivery = true,
     Channel      = channel,
     Data         = msgBuffer,
     LocalUserId  = EOSSDKComponent.LocalUserProductId,
     Reliability  = channels[channel],
     RemoteUserId = host,
     SocketId     = socketId
 });
Esempio n. 7
0
 protected void SendInternal(ProductUserId target, SocketId socketId, InternalMessages type)
 {
     EOSSDKComponent.GetP2PInterface().SendPacket(new SendPacketOptions()
     {
         AllowDelayedDelivery = true,
         Channel      = (byte)internal_ch,
         Data         = new byte[] { (byte)type },
         LocalUserId  = EOSSDKComponent.LocalUserProductId,
         Reliability  = PacketReliability.ReliableOrdered,
         RemoteUserId = target,
         SocketId     = socketId
     });
 }
Esempio n. 8
0
        private IEnumerator ChangeRelayStatus()
        {
            while (!EOSSDKComponent.Initialized)
            {
                yield return(null);
            }

            SetRelayControlOptions setRelayControlOptions = new SetRelayControlOptions();

            setRelayControlOptions.RelayControl = relayControl;

            EOSSDKComponent.GetP2PInterface().SetRelayControl(setRelayControlOptions);
        }
Esempio n. 9
0
        private bool Receive(out ProductUserId clientProductUserId, out SocketId socketId, out byte[] receiveBuffer, byte channel)
        {
            Result result = EOSSDKComponent.GetP2PInterface().ReceivePacket(new ReceivePacketOptions()
            {
                LocalUserId      = EOSSDKComponent.LocalUserProductId,
                MaxDataSizeBytes = P2PInterface.MaxPacketSize,
                RequestedChannel = channel
            }, out clientProductUserId, out socketId, out channel, out receiveBuffer);

            if (result == Result.Success)
            {
                return(true);
            }

            receiveBuffer       = null;
            clientProductUserId = null;
            return(false);
        }
Esempio n. 10
0
        protected void Send(ProductUserId host, SocketId socketId, byte[] msgBuffer, byte channel)
        {
            Result result = EOSSDKComponent.GetP2PInterface().SendPacket(new SendPacketOptions()
            {
                AllowDelayedDelivery = true,
                Channel      = channel,
                Data         = msgBuffer,
                LocalUserId  = EOSSDKComponent.LocalUserProductId,
                Reliability  = channels[channel],
                RemoteUserId = host,
                SocketId     = socketId
            });

            if (result != Result.Success)
            {
                Debug.LogError("Send failed " + result);
            }
        }
Esempio n. 11
0
 protected override void OnNewConnection(OnIncomingConnectionRequestInfo result)
 {
     if (hostProductId == result.RemoteUserId)
     {
         EOSSDKComponent.GetP2PInterface().AcceptConnection(
             new AcceptConnectionOptions()
         {
             LocalUserId  = EOSSDKComponent.LocalUserProductId,
             RemoteUserId = result.RemoteUserId,
             SocketId     = new SocketId()
             {
                 SocketName = SOCKET_ID
             }
         });
     }
     else
     {
         Debug.LogError("P2P Acceptance Request from unknown host ID.");
     }
 }
Esempio n. 12
0
 protected override void OnNewConnection(OnIncomingConnectionRequestInfo result) => EOSSDKComponent.GetP2PInterface().AcceptConnection(
     new AcceptConnectionOptions() {
         LocalUserId = EOSSDKComponent.LocalUserProductId,
         RemoteUserId = result.RemoteUserId,
         SocketId = new SocketId() { SocketName = SOCKET_ID }
     });