コード例 #1
0
    /// <summary>
    /// This is called if the send button
    /// </summary>
    public void SendButtonPressed()
    {
        //get the message written into the text field
        string msg = uMessageField.text;

        if (msg.StartsWith("/disconnect"))
        {
            string[] slt = msg.Split(' ');
            if (slt.Length >= 2)
            {
                ConnectionId conId;
                if (short.TryParse(slt[1], out conId.id))
                {
                    mNetwork.Disconnect(conId);
                }
            }
        }

        //if we are the server -> add 0 in front as the server id
        if (mIsServer)
        {
            //the server has the authority thus -> we can print it directly adding the 0 as server id
            msg = "0: " + msg;
            Append(msg);
            SendString(msg);
        }
        else
        {
            //clients just send it directly to the server. the server will decide what to do with it
            SendString(msg);
        }
        uMessageField.text = "";
    }
コード例 #2
0
 /// <summary>
 /// Disconnects the inner client from the server
 /// </summary>
 /// <returns>If the inner client disconnected successfully</returns>
 public bool Disconnect()
 {
     if (m_Network == null)
     {
         return(false);
     }
     m_Network.Disconnect(CId);
     return(true);
 }
コード例 #3
0
    /// <summary>
    /// This is called if the send button
    /// </summary>
    public void SendButtonPressed()
    {
        //get the message written into the text field
        string msg = uMessageInput.text;


        if (msg.StartsWith("/disconnect"))
        {
            string[] slt = msg.Split(' ');
            if (slt.Length >= 2)
            {
                ConnectionId conId;
                if (short.TryParse(slt[1], out conId.id))
                {
                    mNetwork.Disconnect(conId);
                }
            }
        }

        //if we are the server -> add 0 in front as the server id
        if (mIsServer)
        {
            //the server has the authority thus -> we can print it directly adding the 0 as server id
            msg = "0:" + msg;
            Append(msg);
            SendString(msg);
        }
        else
        {
            //clients just send it directly to the server. the server will decide what to do with it
            SendString(msg);
        }
        uMessageInput.text = "";

        //make sure the text box is in focus again so the user can continue typing without clicking it again
        //select another element first. without this the input field is in focus after return pressed
        uSend.Select();
        uMessageInput.Select();
    }
コード例 #4
0
ファイル: APNetwork.cs プロジェクト: adrenak/airpeer
 /// <summary>
 /// Disconnects using a ConnectionId
 /// </summary>
 /// <param name="id">The Id from which to disconnect</param>
 public void Disconnect(ConnectionId id) => network.Disconnect(id);