コード例 #1
0
        public void UF_SendMessage(string host, int port, int protocol, int corcode, byte[] buffer, int size)
        {
            NetConnection connection = UF_GetConnection(host, port);

            if (connection == null)
            {
                Debugger.UF_Error(string.Format("Send Net Message Error: connection<{0}:{1}> is not Exist | protocol<{2}>", host, port, protocol.ToString("x")));
                return;
            }

            if (connection.connectState == NETCONNECT_STATE.OPENED)
            {
                lock (m_ListConnections) {
                    m_ProtoDataCache.UF_Clear();
                    m_ProtoDataCache.UF_SetID(protocol);
                    m_ProtoDataCache.UF_SetCorCode(corcode);
                    m_ProtoDataCache.UF_SetBodyBuffer(buffer, size);
                    connection.UF_Send(m_ProtoDataCache);

                    Debugger.UF_TrackNetProtol(m_ProtoDataCache.id, m_ProtoDataCache.size, m_ProtoDataCache.corCode);
                }
            }
            else
            {
                Debugger.UF_Error(string.Format("Send Net Message Error: connection<{0}:{1}> is not connected | protocol<{2}>", host, port, protocol.ToString("x")));
            }
        }