예제 #1
0
        protected void _OnText(object[] args)
        {
            SocketronData data    = args[0] as SocketronData;
            Callback      success = args[1] as Callback;
            Callback      error   = args[2] as Callback;

            if (success != null)
            {
                int id = _sequenceId;
                if (_freeIds.Count > 0)
                {
                    id = _freeIds.Pop();
                }
                else
                {
                    _sequenceId++;
                }
                data.SequenceId  = id;
                _successList[id] = success;
                if (error != null)
                {
                    _errorList[id] = error;
                }
            }
            if (LocalConfig.IsDebug && LocalConfig.EnableDebugPayloads)
            {
                _DebugLog("send: {0}", data.Stringify());
            }
            Write(data.ToBuffer(DataType.Text16, LocalConfig.Encoding));
        }
예제 #2
0
 public void WriteTextData(string type, string function, object[] args = null, Callback callback = null)
 {
     _dataCache.SequenceId = null;
     _dataCache.Type       = type;
     _dataCache.Func       = function;
     _dataCache.Args       = args;
     if (callback != null)
     {
         if (_freeIds.Count > 0)
         {
             int id = _freeIds.Pop();
             _dataCache.SequenceId = id;
             _successList[id]      = callback;
         }
         else
         {
             _dataCache.SequenceId       = _sequenceId;
             _successList[_sequenceId++] = callback;
         }
     }
     //Console.WriteLine("data: " + data.Stringify());
     Write(_dataCache.ToBuffer(DataType.Text16, LocalConfig.Encoding));
 }