Exemplo n.º 1
0
		/// <summary>
		/// Tells the client to change their scene to the given scene.  This is often called
		/// after the server has changed to that scene to ensure that the server will always
		/// load up the scene before the client does
		/// </summary>
		/// <param name="netWorker">The current <see cref="NetWorker"/> that will be sending the message</param>
		/// <param name="targetPlayer">The particular player that will be receiving this message</param>
		/// <param name="sceneName">The name of the scene in which the client should load</param>
		public static void ChangeClientScene(NetWorker netWorker, NetworkingPlayer targetPlayer, string sceneName)
		{
			if (!netWorker.IsServer) throw new NetworkException("Only the server can call this method, the specified NetWorker is not a server");

			BMSByte data = new BMSByte();
			data.Clone(Encryptor.Encoding.GetBytes(sceneName));
			data.InsertRange(0, new byte[1] { 2 });
			netWorker.WriteRaw(targetPlayer, data);
		}
Exemplo n.º 2
0
		/// <summary>
		/// Write a custom raw byte message with a 1 byte header across the network
		/// </summary>
		/// <param name="id"></param>
		/// <param name="netWorker"></param>
		/// <param name="data"></param>
		public static void WriteRaw(NetWorker netWorker, BMSByte data)
		{
			if (data == null)
			{
				netWorker.ThrowException(new NetworkException(1000, "The data being written can not be null"));
				return;
			}

			if (data.Size == 0)
			{
				netWorker.ThrowException(new NetworkException(1001, "The data being sent can't be empty"));
				return;
			}

			data.InsertRange(0, rawTypeIndicator);
			netWorker.WriteRaw(data);
		}
Exemplo n.º 3
0
		/// <summary>
		/// Allows the server to send a raw message to a particular player
		/// </summary>
		/// <param name="netWorker"></param>
		/// <param name="targetPlayer"></param>
		/// <param name="data"></param>
		public static void WriteRaw(NetWorker netWorker, NetworkingPlayer targetPlayer, BMSByte data)
		{
			data.InsertRange(0, new byte[1] { 1 });
			netWorker.WriteRaw(targetPlayer, data);
		}
Exemplo n.º 4
0
		public static void DynamicCommand(NetWorker socket, string command, bool relayOnServer = true, bool reliable = true)
		{
			BMSByte data = new BMSByte();
			data.Append(new byte[] { 7 });
			ObjectMapper.MapBytes(data, command);

			socket.WriteRaw(data, "BMS_INTERNAL_Command_" + command, relayOnServer, reliable);
		}
Exemplo n.º 5
0
		/// <summary>
		/// Allows the server to send a raw message to a particular player
		/// </summary>
		/// <param name="netWorker"></param>
		/// <param name="targetPlayer"></param>
		/// <param name="data"></param>
		public static void WriteRaw(NetWorker netWorker, NetworkingPlayer targetPlayer, BMSByte data, string uniqueId, bool reliable = false)
		{
			data.InsertRange(0, new byte[1] { 1 });
			netWorker.WriteRaw(targetPlayer, data, uniqueId, reliable);
		}
Exemplo n.º 6
0
		/// <summary>
		/// Write a custom raw byte message with a 1 byte header across the network
		/// </summary>
		/// <param name="id"></param>
		/// <param name="netWorker"></param>
		/// <param name="data"></param>
		public static void WriteRaw(NetWorker netWorker, BMSByte data, string uniqueId, bool reliable)
		{
			if (data == null)
			{
				netWorker.ThrowException(new NetworkException(1000, "The data being written can not be null"));
				return;
			}

			if (data.Size == 0)
			{
				netWorker.ThrowException(new NetworkException(1001, "The data being sent can't be empty"));
				return;
			}

			netWorker.WriteRaw(data, uniqueId, true, reliable);
		}
Exemplo n.º 7
0
		/// <summary>
		/// Tells the client to change their scene to the given scene.  This is often called
		/// after the server has changed to that scene to ensure that the server will always
		/// load up the scene before the client does
		/// </summary>
		/// <param name="netWorker">The current <see cref="NetWorker"/> that will be sending the message</param>
		/// <param name="targetPlayer">The particular player that will be receiving this message</param>
		/// <param name="sceneName">The name of the scene in which the client should load</param>
		public static void ChangeClientScene(NetWorker netWorker, NetworkingPlayer targetPlayer, string sceneName)
		{
			if (!netWorker.IsServer) throw new NetworkException("Only the server can call this method, the specified NetWorker is not a server");

			BMSByte data = new BMSByte();
			data.Append(new byte[] { 2 });
			ObjectMapper.MapBytes(data, sceneName);

			netWorker.WriteRaw(targetPlayer, data, "BMS_INTERNAL_Change_Client_Scene", true);
		}
Exemplo n.º 8
0
		/// <summary>
		/// This will set the message group for the specified socket connection
		/// </summary>
		/// <param name="socket">The NetWorker to assign the message group for</param>
		/// <param name="groupId">The unique identifier for the message group</param>
		public static void SetMyMessageGroup(NetWorker socket, ushort groupId)
		{
			socket.Me.SetMessageGroup(groupId);

			BMSByte data = new BMSByte();
			data.Append(new byte[] { 6 });
			ObjectMapper.MapBytes(data, groupId);

			socket.WriteRaw(data, "BMS_INTERNAL_Set_MessageGroup", true, true);
		}