UnityEngine.Networking.NetworkConnection.SendByChannel C# (CSharp) Method

SendByChannel() public method

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.
return bool
        public virtual bool SendByChannel(short msgType, MessageBase msg, int channelId)
        {
            this.m_Writer.StartMessage(msgType);
            msg.Serialize(this.m_Writer);
            this.m_Writer.FinishMessage();
            return this.SendWriter(this.m_Writer, channelId);
        }

Usage Example

コード例 #1
0
        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
        }
All Usage Examples Of UnityEngine.Networking.NetworkConnection::SendByChannel