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; }
private Server(EosTransport transport, int maxConnections) : base(transport) { this.maxConnections = maxConnections; epicToMirrorIds = new BidirectionalDictionary <ProductUserId, int>(); epicToSocketIds = new Dictionary <ProductUserId, SocketId>(); nextConnectionID = 1; }
public override void Init() { if (eosTransport is null) { eosTransport = gameObject.AddComponent <EosTransport>(); } Debug.Assert(IsSupported, "This platform is not supported by current transport"); eosTransport.OnClientConnected += OnClientConnect; eosTransport.OnClientDisconnected += OnClientDisconnect; eosTransport.OnClientDataReceived += OnClientDataRecv; eosTransport.OnClientError += OnClientError; eosTransport.OnServerConnected += OnServerConnect; eosTransport.OnServerDisconnected += OnServerDisconnect; eosTransport.OnServerDataReceived += OnServerDataRecv; eosTransport.OnServerError += OnServerError; int count = MLAPI_CHANNELS.Length; eosTransport.Channels = new PacketReliability[count + 3]; eosTransport.Channels[0] = PacketReliability.ReliableOrdered; eosTransport.Channels[1] = PacketReliability.UnreliableUnordered; eosTransport.Channels[2] = PacketReliability.ReliableOrdered; for (int i = 0; i < count; i++) { eosTransport.Channels[i + 3] = ConvertNetworkDelivery(MLAPI_CHANNELS[i].Delivery); } }
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 static Server CreateServer(EosTransport transport, int maxConnections) { Server s = new Server(transport, maxConnections); s.OnConnected += (id) => transport.OnServerConnected.Invoke(id); s.OnDisconnected += (id) => transport.OnServerDisconnected.Invoke(id); s.OnReceivedData += (id, data, channel) => transport.OnServerDataReceived.Invoke(id, new ArraySegment<byte>(data), channel); s.OnReceivedError += (id, exception) => transport.OnServerError.Invoke(id, exception); if (!EOSSDKComponent.Initialized) { Debug.LogError("EOS not initialized."); } return s; }
public static Client CreateClient(EosTransport transport, string host) { Client c = new Client(transport); c.hostAddress = host; c.socketId = new SocketId() { SocketName = RandomString.Generate(20) }; c.OnConnected += () => transport.OnClientConnected.Invoke(); c.OnDisconnected += () => transport.OnClientDisconnected.Invoke(); c.OnReceivedData += (data, channel) => transport.OnClientDataReceived.Invoke(new ArraySegment <byte>(data), channel); return(c); }
public static Client CreateClient(EosTransport transport, string host) { Client c = new Client(transport); c.OnConnected += () => transport.OnClientConnected.Invoke(); c.OnDisconnected += () => transport.OnClientDisconnected.Invoke(); c.OnReceivedData += (data, channel) => transport.OnClientDataReceived.Invoke(new ArraySegment <byte>(data), channel); if (EOSSDKComponent.Initialized) { c.Connect(host); } else { Debug.LogError("EOS not initialized"); c.OnConnectionFailed(null); } return(c); }
private Client(EosTransport transport) : base(transport) { ConnectionTimeout = TimeSpan.FromSeconds(Math.Max(1, transport.timeout)); }