/// <summary>Construct an instance for a connection to an incoming farmhand.</summary> /// <param name="playerID">The player's unique ID.</param> /// <param name="model">The metadata to copy, if available.</param> /// <param name="server">The server through which to send messages.</param> /// <param name="serverConnection">The server connection through which to send messages.</param> public static MultiplayerPeer ForConnectionToFarmhand(long playerID, RemoteContextModel model, SLidgrenServer server, NetConnection serverConnection) { return(new MultiplayerPeer( playerID: playerID, model: model, server: server, serverConnection: serverConnection, client: null, isHost: false )); }
/// <summary>Construct an instance for a connection to the host player.</summary> /// <param name="playerID">The player's unique ID.</param> /// <param name="model">The metadata to copy.</param> /// <param name="client">The client through which to send messages.</param> /// <param name="isHost">Whether this connection is for the host player.</param> public static MultiplayerPeer ForConnectionToHost(long playerID, RemoteContextModel model, SLidgrenClient client, bool isHost) { return(new MultiplayerPeer( playerID: playerID, model: model, server: null, serverConnection: null, client: client, isHost: isHost )); }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="playerID">The player's unique ID.</param> /// <param name="model">The metadata to copy.</param> /// <param name="sendMessage">A method which sends a message to the peer.</param> /// <param name="isHost">Whether this is a connection to the host player.</param> public MultiplayerPeer(long playerID, RemoteContextModel model, Action <OutgoingMessage> sendMessage, bool isHost) { this.PlayerID = playerID; this.IsHost = isHost; if (model != null) { this.Platform = model.Platform; this.GameVersion = model.GameVersion; this.ApiVersion = model.ApiVersion; this.Mods = model.Mods.Select(mod => new MultiplayerPeerMod(mod)).ToArray(); } this.SendMessageImpl = sendMessage; }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="playerID">The player's unique ID.</param> /// <param name="model">The metadata to copy.</param> /// <param name="server">The server through which to send messages.</param> /// <param name="serverConnection">The server connection through which to send messages.</param> /// <param name="client">The client through which to send messages.</param> /// <param name="isHost">Whether this is a connection to the host player.</param> public MultiplayerPeer(long playerID, RemoteContextModel model, SLidgrenServer server, NetConnection serverConnection, SLidgrenClient client, bool isHost) { this.PlayerID = playerID; this.IsHost = isHost; if (model != null) { this.Platform = model.Platform; this.GameVersion = model.GameVersion; this.ApiVersion = model.ApiVersion; this.Mods = model.Mods.Select(mod => new MultiplayerPeerMod(mod)).ToArray(); } this.Server = server; this.ServerConnection = serverConnection; this.Client = client; }