Example #1
0
        /// <summary>
        /// Sends the stream.
        /// </summary>
        /// <returns><c>true</c>, if stream was sent, <c>false</c> otherwise.</returns>
        /// <param name="buffer">The object you wish to send as a serialized stream.</param>
        /// <param name="size">Max buffer size for your data.</param>
        /// <param name="channel">The channel to send the data on.</param>
        public bool SendStream(byte[] buffer, int size, int channel)
        {
            byte error;

            NetworkTransport.Send(mSocket, mConnection, channel, buffer, size, out error);

            if (NetUtils.IsNetworkError(error))
            {
                Debug.Log("NetClient::SendStream( " + buffer.ToString() + " , " + size.ToString() + " ) Failed with reason '" + NetUtils.GetNetworkError(error) + "'.");
                return(false);
            }

            return(true);
        }
Example #2
0
        /// <summary>
        /// Connect the specified ip and port.
        /// </summary>
        /// <param name="ip">Ip.</param>
        /// <param name="port">Port.</param>
        public bool Connect(string ip, int port)
        {
            byte error;

            mConnection = NetworkTransport.Connect(mSocket, ip, port, 0, out error);

            if (NetUtils.IsNetworkError(error))
            {
                Debug.Log("NetClient::Connect( " + ip + " , " + port.ToString() + " ) Failed with reason '" + NetUtils.GetNetworkError(error) + "'.");
                return(false);
            }

            mServerIP = ip;
            mPort     = port;

            return(true);
        }