コード例 #1
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);
        }
コード例 #2
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");
            }

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

            this.transport = transport;
        }
コード例 #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;
        }
コード例 #4
0
        internal static void OnRemoteConnectionClosed(IntPtr address)
        {
            OnRemoteConnectionClosedCallback callback     = null;
            OnRemoteConnectionClosedInfo     callbackInfo = null;

            if (Helper.TryGetAndRemoveCallback <OnRemoteConnectionClosedCallback, OnRemoteConnectionClosedInfoInternal, OnRemoteConnectionClosedInfo>(address, out callback, out callbackInfo))
            {
                callback(callbackInfo);
            }
        }
コード例 #5
0
        /// <summary>
        /// Listen for when a previously opened connection is closed
        /// </summary>
        /// <param name="options">Information about who would like notifications about closed connections, and for which socket</param>
        /// <param name="clientData">This value is returned to the caller when ConnectionClosedHandler is invoked</param>
        /// <param name="connectionClosedHandler">The callback to be fired when we an open connection has been closed</param>
        /// <returns>
        /// A valid notification ID if successfully bound, or <see cref="Common.InvalidNotificationid" /> otherwise
        /// </returns>
        public ulong AddNotifyPeerConnectionClosed(AddNotifyPeerConnectionClosedOptions options, object clientData, OnRemoteConnectionClosedCallback connectionClosedHandler)
        {
            System.IntPtr optionsAddress = new System.IntPtr();
            Helper.TryMarshalSet <AddNotifyPeerConnectionClosedOptionsInternal, AddNotifyPeerConnectionClosedOptions>(ref optionsAddress, options);

            var clientDataAddress = System.IntPtr.Zero;

            var connectionClosedHandlerInternal = new OnRemoteConnectionClosedCallbackInternal(OnRemoteConnectionClosedCallbackInternalImplementation);

            Helper.AddCallback(ref clientDataAddress, clientData, connectionClosedHandler, connectionClosedHandlerInternal);

            var funcResult = EOS_P2P_AddNotifyPeerConnectionClosed(InnerHandle, optionsAddress, clientDataAddress, connectionClosedHandlerInternal);

            Helper.TryMarshalDispose(ref optionsAddress);

            Helper.TryAssignNotificationIdToCallback(clientDataAddress, funcResult);

            return(funcResult);
        }
コード例 #6
0
        /// <summary>
        /// Short AddNotifyPeerConnectionClosed
        /// </summary>
        /// <param name="p2p">P2PInterface</param>
        /// <param name="socketName">Socket name</param>
        /// <param name="localUserId">Login user id</param>
        public static void AddNotifyPeerConnectionClosed(this P2PInterface p2p, string socketName, ProductUserId localUserId, OnRemoteConnectionClosedCallback fun)
        {
            var op = new AddNotifyPeerConnectionClosedOptions
            {
                SocketId = new SocketId
                {
                    SocketName = socketName
                },
                LocalUserId = localUserId,
            };

            p2p.AddNotifyPeerConnectionClosed(op, null, fun);
        }
コード例 #7
0
        /// <summary>
        /// Listen for when a previously opened connection is closed
        /// </summary>
        /// <param name="options">Information about who would like notifications about closed connections, and for which socket</param>
        /// <param name="clientData">This value is returned to the caller when ConnectionClosedHandler is invoked</param>
        /// <param name="connectionClosedHandler">The callback to be fired when we an open connection has been closed</param>
        /// <returns>
        /// A valid notification ID if successfully bound, or <see cref="Common.InvalidNotificationid" /> otherwise
        /// </returns>
        public ulong AddNotifyPeerConnectionClosed(AddNotifyPeerConnectionClosedOptions options, object clientData, OnRemoteConnectionClosedCallback connectionClosedHandler)
        {
            var optionsInternal = Helper.CopyProperties <AddNotifyPeerConnectionClosedOptionsInternal>(options);

            var connectionClosedHandlerInternal = new OnRemoteConnectionClosedCallbackInternal(OnRemoteConnectionClosed);
            var clientDataAddress = IntPtr.Zero;

            Helper.AddCallback(ref clientDataAddress, clientData, connectionClosedHandler, connectionClosedHandlerInternal);

            var funcResult = EOS_P2P_AddNotifyPeerConnectionClosed(InnerHandle, ref optionsInternal, clientDataAddress, connectionClosedHandlerInternal);

            Helper.TryMarshalDispose(ref optionsInternal);

            Helper.TryAssignNotificationIdToCallback(clientDataAddress, funcResult);

            var funcResultReturn = Helper.GetDefault <ulong>();

            Helper.TryMarshalGet(funcResult, out funcResultReturn);
            return(funcResultReturn);
        }