protected void Dispose() { EOSSDKComponent.GetP2PInterface().RemoveNotifyPeerConnectionRequest(incomingNotificationId); EOSSDKComponent.GetP2PInterface().RemoveNotifyPeerConnectionClosed(outgoingNotificationId); transport.ResetIgnoreMessagesAtStartUpTimer(); }
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; }
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; }
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."); } }
protected void CloseP2PSessionWithUser(ProductUserId clientUserID) => EOSSDKComponent.GetP2PInterface().CloseConnection( new CloseConnectionOptions() { LocalUserId = EOSSDKComponent.LocalUserProductId, RemoteUserId = clientUserID, SocketId = new SocketId() { SocketName = SOCKET_ID } });
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 });
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 }); }
private IEnumerator ChangeRelayStatus() { while (!EOSSDKComponent.Initialized) { yield return(null); } SetRelayControlOptions setRelayControlOptions = new SetRelayControlOptions(); setRelayControlOptions.RelayControl = relayControl; EOSSDKComponent.GetP2PInterface().SetRelayControl(setRelayControlOptions); }
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); }
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); } }
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."); } }
protected override void OnNewConnection(OnIncomingConnectionRequestInfo result) => EOSSDKComponent.GetP2PInterface().AcceptConnection( new AcceptConnectionOptions() { LocalUserId = EOSSDKComponent.LocalUserProductId, RemoteUserId = result.RemoteUserId, SocketId = new SocketId() { SocketName = SOCKET_ID } });