コード例 #1
0
        protected void Dispose()
        {
            EOSSDKComponent.GetP2PInterface().RemoveNotifyPeerConnectionRequest(incomingNotificationId);
            EOSSDKComponent.GetP2PInterface().RemoveNotifyPeerConnectionClosed(outgoingNotificationId);

            transport.ResetIgnoreMessagesAtStartUpTimer();
        }
コード例 #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;
        }
コード例 #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;
        }
コード例 #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.");
            }
        }
コード例 #5
0
 protected void CloseP2PSessionWithUser(ProductUserId clientUserID) => EOSSDKComponent.GetP2PInterface().CloseConnection(
     new CloseConnectionOptions()
 {
     LocalUserId  = EOSSDKComponent.LocalUserProductId,
     RemoteUserId = clientUserID,
     SocketId     = new SocketId()
     {
         SocketName = SOCKET_ID
     }
 });
コード例 #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
 });
コード例 #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
     });
 }
コード例 #8
0
        private IEnumerator ChangeRelayStatus()
        {
            while (!EOSSDKComponent.Initialized)
            {
                yield return(null);
            }

            SetRelayControlOptions setRelayControlOptions = new SetRelayControlOptions();

            setRelayControlOptions.RelayControl = relayControl;

            EOSSDKComponent.GetP2PInterface().SetRelayControl(setRelayControlOptions);
        }
コード例 #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);
        }
コード例 #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);
            }
        }
コード例 #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.");
     }
 }
コード例 #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 }
     });