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); } } }
private void Send(INatterConnection connection, int num) { var data = new FieldData(); data.Add(DataField, num.ToString()); connection.Send(data); }
private void OnDisconnected(INatterConnection connection) { if (_onDisconnected != null) { _onDisconnected(connection); } }
private void OnError(INatterConnection connection, Exception error) { if (_onError != null) { _onError(connection, error); } }
private void OnData(INatterConnection connection, FieldData data) { if (_onData != null) { _onData(connection, data); } }