コード例 #1
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;
        }
コード例 #2
0
        protected Common(EpicTransport transport, EpicOptions options)
        {
            Transport   = transport;
            EpicManager = Transport.EpicManager;
            Options     = options;

            AddNotifyPeerConnectionRequestOptions addNotifyPeerConnectionRequestOptions =
                new AddNotifyPeerConnectionRequestOptions {
                LocalUserId = EpicManager.AccountId.ProductUserId
            };

            _onIncomingConnectionRequest += OnNewConnection;
            _onRemoteConnectionClosed    += OnConnectionFailed;

            _incomingNotificationId = EpicManager.P2PInterface.AddNotifyPeerConnectionRequest(addNotifyPeerConnectionRequestOptions,
                                                                                              null, _onIncomingConnectionRequest);

            AddNotifyPeerConnectionClosedOptions addNotifyPeerConnectionClosedOptions =
                new AddNotifyPeerConnectionClosedOptions
            {
                LocalUserId = EpicManager.AccountId.ProductUserId
            };

            _outgoingNotificationId = EpicManager.P2PInterface.AddNotifyPeerConnectionClosed(addNotifyPeerConnectionClosedOptions,
                                                                                             null, _onRemoteConnectionClosed);
        }
コード例 #3
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;
        }
 public void Set(AddNotifyPeerConnectionRequestOptions other)
 {
     if (other != null)
     {
         m_ApiVersion = P2PInterface.AddnotifypeerconnectionrequestApiLatest;
         LocalUserId  = other.LocalUserId;
         SocketId     = other.SocketId;
     }
 }
コード例 #5
0
        /// <summary>
        /// 短縮 AddNotifyPeerConnectionRequest
        /// </summary>
        /// <param name="p2p">P2PInterface</param>
        /// <param name="socketName">ソケット名</param>
        /// <param name="localUserId">ログインユーザーID</param>
        public static void AddNotifyPeerConnectionRequest(this P2PInterface p2p, string socketName, ProductUserId localUserId, OnIncomingConnectionRequestCallback fun)
        {
            var op = new AddNotifyPeerConnectionRequestOptions
            {
                SocketId = new SocketId
                {
                    SocketName = socketName
                },
                LocalUserId = localUserId,
            };

            p2p.AddNotifyPeerConnectionRequest(op, null, fun);
        }
コード例 #6
0
        /// <summary>
        /// Listen for incoming connection requests on a particular Socket ID, or optionally all Socket IDs. The bound function
        /// will only be called if the connection has not already been accepted.
        /// </summary>
        /// <param name="options">Information about who would like notifications, and (optionally) only for a specific socket</param>
        /// <param name="clientData">This value is returned to the caller when ConnectionRequestHandler is invoked</param>
        /// <param name="connectionRequestHandler">The callback to be fired when we receive a connection request</param>
        /// <returns>
        /// A valid notification ID if successfully bound, or <see cref="Common.InvalidNotificationid" /> otherwise
        /// </returns>
        public ulong AddNotifyPeerConnectionRequest(AddNotifyPeerConnectionRequestOptions options, object clientData, OnIncomingConnectionRequestCallback connectionRequestHandler)
        {
            System.IntPtr optionsAddress = new System.IntPtr();
            Helper.TryMarshalSet <AddNotifyPeerConnectionRequestOptionsInternal, AddNotifyPeerConnectionRequestOptions>(ref optionsAddress, options);

            var clientDataAddress = System.IntPtr.Zero;

            var connectionRequestHandlerInternal = new OnIncomingConnectionRequestCallbackInternal(OnIncomingConnectionRequestCallbackInternalImplementation);

            Helper.AddCallback(ref clientDataAddress, clientData, connectionRequestHandler, connectionRequestHandlerInternal);

            var funcResult = EOS_P2P_AddNotifyPeerConnectionRequest(InnerHandle, optionsAddress, clientDataAddress, connectionRequestHandlerInternal);

            Helper.TryMarshalDispose(ref optionsAddress);

            Helper.TryAssignNotificationIdToCallback(clientDataAddress, funcResult);

            return(funcResult);
        }