protected Common(HeathenSteamGameServerTransport transport) { channels = transport.Channels; callback_OnNewConnection = Callback <P2PSessionRequest_t> .Create(OnNewConnection); callback_OnConnectFail = Callback <P2PSessionConnectFail_t> .Create(OnConnectFail); this.transport = transport; }
public static Server CreateServer(HeathenSteamGameServerTransport 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 (!SteamManager.Initialized) { Debug.LogError("SteamWorks not initialized."); } return(s); }
public static Client CreateClient(HeathenSteamGameServerTransport 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 (SteamManager.Initialized) { c.Connect(host); } else { Debug.LogError("SteamWorks not initialized"); c.OnConnectionFailed(CSteamID.Nil); } return(c); }
private Server(HeathenSteamGameServerTransport transport, int maxConnections) : base(transport) { this.maxConnections = maxConnections; steamToMirrorIds = new BidirectionalDictionary <CSteamID, int>(); nextConnectionID = 1; }
private Client(HeathenSteamGameServerTransport transport) : base(transport) { ConnectionTimeout = TimeSpan.FromSeconds(Math.Max(1, transport.Timeout)); }