Пример #1
0
        public OldMessageHandler(OCNetworkElement ne, Socket socket)
        {
            this.ne        = ne;
            this.socket    = socket;
            this.lineCount = 0;
            this.state     = DOING_NOTHING;

            this.currentMessageTo   = null;
            this.currentMessageFrom = null;
            this.currentMessage     = new StringBuilder();
            this.messageBuffer      = new List <OCMessage>();

            this.thread = new Thread(this.run);
        }
        /// <summary>
        /// Parse a text line from message received.
        /// </summary>
        /// <param name='inputLine'>
        /// The raw data that received by server socket.
        /// </param>
        /// <returns>
        /// An 'OK' string if the line was successfully parsed,
        /// a 'FAILED' string if something went wrong,
        /// null if there is still more to parse.
        /// </returns>
        private string Parse(string inputLine)
        {
            UnityEngine.Debug.Log("OCMessageHandler::Parse (" + inputLine + ")");

            string answer = null;

            if (_networkElement == null)
            {
                _networkElement = OCNetworkElement.Instance;
            }

            UnityEngine.Debug.Log("_networkElement == null? I wonder..." + ((_networkElement == null) ? "yes...it is..." : "no...it isn't"));

//		if (_networkElement != null) {
//			//UnityEngine.Debug.Log ("OCMessageHandler is using a NetworkElement with ID " + _networkElement.VerificationGuid + "...");
//		}
//		else {
//			//UnityEngine.Debug.Log("_networkElement == null");
//		}

            char selector = inputLine[0];

            if (selector == 'c')
            {
                answer = ParseCMessage(inputLine);
            }
            else if (selector == 'd')
            {
                answer = ParseDMessage(inputLine);
            }
            else
            {
                OCLogger.Error("onLine: Invalid selector [" + selector
                               + "]. Discarding line [" + inputLine + "].");
                answer = OCNetworkElement.FAILED_MESSAGE;
            }

            return(answer);
        }
Пример #3
0
 /// <summary>
 /// Initializes this instance.  Set default values here.
 /// </summary>
 public void InitFromNetwork(OCNetworkElement networkElement)
 {
     _networkElement = networkElement;
     _sockets        = new List <System.Net.Sockets.Socket>();
     _shouldStop     = false;
 }
Пример #4
0
 /// <summary>
 /// Initializes this instance.  Set default values here.
 /// </summary>
 public void Initialize(OCNetworkElement networkElement)
 {
     _networkElement = networkElement;
     _shouldStop     = false;
 }