mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
cleanup
This commit is contained in:
parent
7d397d9172
commit
51f5dd52a9
@ -183,10 +183,7 @@ static void OnConnected()
|
|||||||
else Debug.LogError("Skipped Connect message handling because connection is null.");
|
else Debug.LogError("Skipped Connect message handling because connection is null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>Disconnect from server.</summary>
|
||||||
/// Disconnect from server.
|
|
||||||
/// <para>The disconnect message will be invoked.</para>
|
|
||||||
/// </summary>
|
|
||||||
public static void Disconnect()
|
public static void Disconnect()
|
||||||
{
|
{
|
||||||
connectState = ConnectState.Disconnected;
|
connectState = ConnectState.Disconnected;
|
||||||
@ -219,14 +216,7 @@ public static void Disconnect()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>Send a NetworkMessage to the server over the given channel.</summary>
|
||||||
/// This sends a network message with a message Id to the server. This message is sent on channel zero, which by default is the reliable channel.
|
|
||||||
/// <para>The message must be an instance of a class derived from MessageBase.</para>
|
|
||||||
/// <para>The message id passed to Send() is used to identify the handler function to invoke on the server when the message is received.</para>
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The message type to unregister.</typeparam>
|
|
||||||
/// <param name="message"></param>
|
|
||||||
/// <param name="channelId"></param>
|
|
||||||
public static void Send<T>(T message, int channelId = Channels.DefaultReliable)
|
public static void Send<T>(T message, int channelId = Channels.DefaultReliable)
|
||||||
where T : struct, NetworkMessage
|
where T : struct, NetworkMessage
|
||||||
{
|
{
|
||||||
@ -309,13 +299,7 @@ internal static void RegisterSystemHandlers(bool hostMode)
|
|||||||
RegisterHandler<RpcMessage>(ClientScene.OnRPCMessage);
|
RegisterHandler<RpcMessage>(ClientScene.OnRPCMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>Register a handler for a message type T. Most should require authentication.</summary>
|
||||||
/// Register a handler for a particular message type.
|
|
||||||
/// <para>There are several system message types which you can add handlers for. You can also add your own message types.</para>
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">Message type</typeparam>
|
|
||||||
/// <param name="handler">Function handler which will be invoked when this message type is received.</param>
|
|
||||||
/// <param name="requireAuthentication">True if the message requires an authenticated connection</param>
|
|
||||||
public static void RegisterHandler<T>(Action<NetworkConnection, T> handler, bool requireAuthentication = true)
|
public static void RegisterHandler<T>(Action<NetworkConnection, T> handler, bool requireAuthentication = true)
|
||||||
where T : struct, NetworkMessage
|
where T : struct, NetworkMessage
|
||||||
{
|
{
|
||||||
@ -327,26 +311,14 @@ public static void RegisterHandler<T>(Action<NetworkConnection, T> handler, bool
|
|||||||
handlers[msgType] = MessagePacking.WrapHandler(handler, requireAuthentication);
|
handlers[msgType] = MessagePacking.WrapHandler(handler, requireAuthentication);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>Register a handler for a message type T. Most should require authentication.</summary>
|
||||||
/// Register a handler for a particular message type.
|
|
||||||
/// <para>There are several system message types which you can add handlers for. You can also add your own message types.</para>
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">Message type</typeparam>
|
|
||||||
/// <param name="handler">Function handler which will be invoked when this message type is received.</param>
|
|
||||||
/// <param name="requireAuthentication">True if the message requires an authenticated connection</param>
|
|
||||||
public static void RegisterHandler<T>(Action<T> handler, bool requireAuthentication = true)
|
public static void RegisterHandler<T>(Action<T> handler, bool requireAuthentication = true)
|
||||||
where T : struct, NetworkMessage
|
where T : struct, NetworkMessage
|
||||||
{
|
{
|
||||||
RegisterHandler((NetworkConnection _, T value) => { handler(value); }, requireAuthentication);
|
RegisterHandler((NetworkConnection _, T value) => { handler(value); }, requireAuthentication);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>Replace a handler for a particular message type. Should require authentication by default.</summary>
|
||||||
/// Replaces a handler for a particular message type.
|
|
||||||
/// <para>See also <see cref="RegisterHandler{T}(Action{NetworkConnection, T}, bool)">RegisterHandler(T)(Action(NetworkConnection, T), bool)</see></para>
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">Message type</typeparam>
|
|
||||||
/// <param name="handler">Function handler which will be invoked when this message type is received.</param>
|
|
||||||
/// <param name="requireAuthentication">True if the message requires an authenticated connection</param>
|
|
||||||
public static void ReplaceHandler<T>(Action<NetworkConnection, T> handler, bool requireAuthentication = true)
|
public static void ReplaceHandler<T>(Action<NetworkConnection, T> handler, bool requireAuthentication = true)
|
||||||
where T : struct, NetworkMessage
|
where T : struct, NetworkMessage
|
||||||
{
|
{
|
||||||
@ -354,23 +326,14 @@ public static void ReplaceHandler<T>(Action<NetworkConnection, T> handler, bool
|
|||||||
handlers[msgType] = MessagePacking.WrapHandler(handler, requireAuthentication);
|
handlers[msgType] = MessagePacking.WrapHandler(handler, requireAuthentication);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>Replace a handler for a particular message type. Should require authentication by default.</summary>
|
||||||
/// Replaces a handler for a particular message type.
|
|
||||||
/// <para>See also <see cref="RegisterHandler{T}(Action{NetworkConnection, T}, bool)">RegisterHandler(T)(Action(NetworkConnection, T), bool)</see></para>
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">Message type</typeparam>
|
|
||||||
/// <param name="handler">Function handler which will be invoked when this message type is received.</param>
|
|
||||||
/// <param name="requireAuthentication">True if the message requires an authenticated connection</param>
|
|
||||||
public static void ReplaceHandler<T>(Action<T> handler, bool requireAuthentication = true)
|
public static void ReplaceHandler<T>(Action<T> handler, bool requireAuthentication = true)
|
||||||
where T : struct, NetworkMessage
|
where T : struct, NetworkMessage
|
||||||
{
|
{
|
||||||
ReplaceHandler((NetworkConnection _, T value) => { handler(value); }, requireAuthentication);
|
ReplaceHandler((NetworkConnection _, T value) => { handler(value); }, requireAuthentication);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>Unregister a message handler of type T.</summary>
|
||||||
/// Unregisters a network message handler.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The message type to unregister.</typeparam>
|
|
||||||
public static bool UnregisterHandler<T>()
|
public static bool UnregisterHandler<T>()
|
||||||
where T : struct, NetworkMessage
|
where T : struct, NetworkMessage
|
||||||
{
|
{
|
||||||
@ -379,10 +342,7 @@ public static bool UnregisterHandler<T>()
|
|||||||
return handlers.Remove(msgType);
|
return handlers.Remove(msgType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>Shutdown the client.</summary>
|
||||||
/// Shut down a client.
|
|
||||||
/// <para>This should be done when a client is no longer going to be used.</para>
|
|
||||||
/// </summary>
|
|
||||||
public static void Shutdown()
|
public static void Shutdown()
|
||||||
{
|
{
|
||||||
Debug.Log("Shutting down client.");
|
Debug.Log("Shutting down client.");
|
||||||
|
Loading…
Reference in New Issue
Block a user