public SendByChannel ( short msgType, |
||
msgType | short | The message ID to send. |
msg | The message to send. | |
channelId | int | The transport layer channel to send on. |
return | bool |
protected void SendTargetRPCInternal(NetworkConnection conn, int rpcHash, NetworkWriter writer, int channelId, string rpcName) { // This cannot use NetworkServer.active, as that is not specific to this object. if (!isServer) { if (LogFilter.logWarn) { Debug.LogWarning("TargetRpc call on un-spawned object"); } return; } // construct the message RpcMessage message = new RpcMessage(); message.netId = netId; message.rpcHash = rpcHash; message.payload = writer.ToArray(); conn.SendByChannel((short)MsgType.Rpc, message, channelId); #if UNITY_EDITOR UnityEditor.NetworkDetailStats.IncrementStat( UnityEditor.NetworkDetailStats.NetworkDirection.Outgoing, (short)MsgType.Rpc, rpcName, 1); #endif }
public bool SendByChannel(short msgType, MessageBase msg, int channelId) { #if UNITY_EDITOR UnityEditor.NetworkDetailStats.IncrementStat( UnityEditor.NetworkDetailStats.NetworkDirection.Outgoing, MsgType.UserMessage, msgType.ToString() + ":" + msg.GetType().Name, 1); #endif if (m_Connection != null) { if (m_AsyncConnect != ConnectState.Connected) { if (LogFilter.logError) { Debug.LogError("NetworkClient SendByChannel when not connected to a server"); } return(false); } return(m_Connection.SendByChannel(msgType, msg, channelId)); } if (LogFilter.logError) { Debug.LogError("NetworkClient SendByChannel with no connection"); } return(false); }
private static void ClientsideConnect(UnityEngine.Networking.NetworkConnection connection) { try { ModListMessage msg = new ModListMessage(localModList, false); connection.SendByChannel(messageIndex, msg, QosChannelIndex.defaultReliable.intVal); MessageWaitClientAsync(connection, messageWaitTimeClient); } catch (Exception e) { Fail(e, "ClientsideConnect"); } }
public bool SendByChannel(short msgType, MessageBase msg, int channelId) { if (m_Connection != null) { if (m_AsyncConnect != ConnectState.Connected) { if (LogFilter.logError) { Debug.LogError("NetworkClient SendByChannel when not connected to a server"); } return(false); } return(m_Connection.SendByChannel(msgType, msg, channelId)); } if (LogFilter.logError) { Debug.LogError("NetworkClient SendByChannel with no connection"); } return(false); }
// =========================================================================== // ========================= SEND FUNCTIONS ========================= // =========================================================================== void ServerSendMessage(Message.ID id, MessageBase msg, byte channel, NetworkConnection conn) { if(conn != null) conn.SendByChannel((short)id, msg, channel); else common.printConsole (tag, "Is not connected to client " + conn.address, true); }