示例#1
0
        private void HandleResponse(FieldData data, INatterConnection connection)
        {
            if (data.ContainsKey(DataField))
            {
                _count++;
                _lastResult = int.Parse(data.GetStringValue(DataField));
                Console.WriteLine("Last number was: {0}", _lastResult);

                if (_lastResult == EndNumber)
                {
                    connection.Close();
                }
                else
                {
                    Send(connection, _lastResult + 1);
                }
            }
        }
示例#2
0
 private void Send(INatterConnection connection, int num)
 {
     var data = new FieldData();
     data.Add(DataField, num.ToString());
     connection.Send(data);
 }
示例#3
0
 private void OnDisconnected(INatterConnection connection)
 {
     if (_onDisconnected != null)
     {
         _onDisconnected(connection);
     }
 }
示例#4
0
 private void OnError(INatterConnection connection, Exception error)
 {
     if (_onError != null)
     {
         _onError(connection, error);
     }
 }
示例#5
0
 private void OnData(INatterConnection connection, FieldData data)
 {
     if (_onData != null)
     {
         _onData(connection, data);
     }
 }