SendByChannel() 공개 메소드

This sends a network message on the connection using a specific transport layer channel.

public SendByChannel ( short msgType, MessageBase msg, int channelId ) : bool
msgType short The message ID to send.
msg MessageBase The message to send.
channelId int The transport layer channel to send on.
리턴 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
        }
예제 #2
0
        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);
        }
예제 #3
0
 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");
     }
 }
예제 #4
0
 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);
 }
예제 #5
0
		// ===========================================================================
		// ========================= 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);
		}