Ejemplo n.º 1
0
 public static NPMessage FromValue(object val, NPMessageType type = NPMessageType.Response, string text = null)
 {
     return(new NPMessage(type, new NPMessageNamepathData[]
     {
         new NPMessageNamepathData("", val)
     }, text));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Sends a message and waits for response if needed.
        /// </summary>
        /// <param name="msg">The message to send</param>
        /// <param name="requireResponse">If true a response will be required from the other party. Synchronius action.</param>
        /// <param name="toWebsocket">If null then broadcase (as a server, this would mean sending to all clients)</param>
        /// <returns>The response if required, otherwise null.</returns>
        public NPMessage Send(NPMessageType type, string msg, NPMessageNamepathData[] data, bool requireResponse = false, string toWebsocket = null)
        {
            if (toWebsocket != null)
            {
                toWebsocket = toWebsocket.Trim();
                toWebsocket = toWebsocket.Length == 0 ? null : toWebsocket;
            }

            return(Send(new NPMessage(type, data, msg), requireResponse, toWebsocket));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Make a JMessage from namepaths data
        /// </summary>
        /// <param name="namepaths"></param>
        /// <param name="values"></param>
        public NPMessage(NPMessageType type, NPMessageNamepathData[] data, string message = null)
        {
            if (data == null)
            {
                data = new NPMessageNamepathData[0];
            }

            m_NamePaths = data;
            Text        = message;
            MessageType = type;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Sends a message and waits for response if needed.
 /// </summary>
 /// <param name="msg">The message to send</param>
 /// <param name="requireResponse">If true a response will be required from the other party. Synchronius action.</param>
 /// <param name="toWebsocket">If null then broadcase (as a server, this would mean sending to all clients)</param>
 /// <returns>The response if required, otherwise null.</returns>
 public NPMessage Send(NPMessageType type, string msg, NPMessageNamepathData data, bool requireResponse = false, string toWebsocket = null)
 {
     return(Send(type, msg, data == null ? null : new NPMessageNamepathData[1] {
         data
     }, requireResponse, toWebsocket));
 }