@@ -14,36 +14,36 @@ public class ClientConnection : EncryptedTcpConnection
1414 private ClientConnection ( Socket socket ) : base ( socket )
1515 {
1616 _rc4 = new Rc4 ( FastRandom . NextBytes ( 40 ) ) ;
17- ObjectHelper . Swap ( ref inIncrement , ref outIncrement ) ;
18- ObjectHelper . Swap ( ref inDecodingByte , ref outEncodingByte ) ;
17+ ObjectHelper . Swap ( ref inIncrement , ref outIncrement ) ;
18+ ObjectHelper . Swap ( ref inDecodingByte , ref outEncodingByte ) ;
1919 }
2020
2121 protected override void OnReceived ( byte [ ] data )
2222 {
2323 _rc4 . Decrypt ( data , 1 , data . Length - 1 ) ;
2424
25- var dataOffset = 4 ;
25+ int dataOffset = 4 ;
2626
27- var compressionLevel = data [ 0 ] ;
27+ byte compressionLevel = data [ 0 ] ;
2828 if ( compressionLevel == 2 )
2929 {
3030 data = GZip . Decompress ( data , 5 ) ;
3131 dataOffset -- ;
3232 }
3333
34- var messageText = Encoding . UTF8 . GetString ( data , dataOffset , data . Length - dataOffset ) ;
34+ string messageText = Encoding . UTF8 . GetString ( data , dataOffset , data . Length - dataOffset ) ;
3535 OnReceived ( messageText ) ;
3636
3737 base . OnReceived ( data ) ;
3838 }
3939
4040 public new event Action < string > Received ;
4141
42- private readonly ConcurrentDictionary < Command , ConcurrentQueue < TaskCompletionSource < IMessage > > > _commandQueue = new ConcurrentDictionary < Command , ConcurrentQueue < TaskCompletionSource < IMessage > > > ( ) ;
42+ private readonly ConcurrentDictionary < Command , ConcurrentQueue < TaskCompletionSource < IMessage > > > _commandQueue = new ConcurrentDictionary < Command , ConcurrentQueue < TaskCompletionSource < IMessage > > > ( ) ;
4343
4444 public IMessage Send ( Command command )
4545 {
46- var t = SendAsync ( command ) ;
46+ Task < IMessage > t = SendAsync ( command ) ;
4747 return t . Result ;
4848 }
4949
@@ -54,49 +54,49 @@ public Task<IMessage> SendAsync(Command command)
5454
5555 public IMessage Send ( string messageText )
5656 {
57- var t = SendAsync ( messageText ) ;
57+ Task < IMessage > t = SendAsync ( messageText ) ;
5858 return t . Result ;
5959 }
6060
6161 public Task < IMessage > SendAsync ( string messageText )
6262 {
63- var m = Message . Parse ( messageText ) ;
63+ Message m = Message . Parse ( messageText ) ;
6464 return SendAsync ( m ) ;
6565 }
6666
6767 public IMessage Send ( IMessage clientMessage )
6868 {
69- var t = SendAsync ( clientMessage ) ;
69+ Task < IMessage > t = SendAsync ( clientMessage ) ;
7070 return t . Result ;
7171 }
7272
7373 public Task < IMessage > SendAsync ( IMessage clientMessage )
7474 {
75- var source = new TaskCompletionSource < IMessage > ( ) ;
76- EnqueueCompletionSource ( clientMessage . Command , source ) ;
75+ TaskCompletionSource < IMessage > source = new TaskCompletionSource < IMessage > ( ) ;
76+ EnqueueCompletionSource ( clientMessage . Command , source ) ;
7777 Send ( clientMessage . ToBytes ( ) ) ;
7878 return source . Task ;
7979 }
8080
81- private void EnqueueCompletionSource ( Command command , TaskCompletionSource < IMessage > source )
81+ private void EnqueueCompletionSource ( Command command , TaskCompletionSource < IMessage > source )
8282 {
83- var q = _commandQueue . GetOrAdd ( command , ( ) => new ConcurrentQueue < TaskCompletionSource < IMessage > > ( ) ) ;
83+ ConcurrentQueue < TaskCompletionSource < IMessage > > q = _commandQueue . GetOrAdd ( command , ( ) => new ConcurrentQueue < TaskCompletionSource < IMessage > > ( ) ) ;
8484 q . Enqueue ( source ) ;
8585 }
8686
8787 public override void Send ( byte [ ] data )
8888 {
89- var t = new byte [ data . Length + 4 ] ;
90- Array . Copy ( data , 0 , t , 4 , data . Length ) ;
91- _rc4 . Encrypt ( t , 1 , t . Length - 1 ) ;
89+ byte [ ] t = new byte [ data . Length + 4 ] ;
90+ Array . Copy ( data , 0 , t , 4 , data . Length ) ;
91+ _rc4 . Encrypt ( t , 1 , t . Length - 1 ) ;
9292 base . Send ( t ) ;
9393 }
9494
9595 public static ClientConnection Connect ( IPEndPoint endPoint )
9696 {
97- var socket = new Socket ( AddressFamily . InterNetwork , SocketType . Stream , ProtocolType . Tcp ) ;
97+ Socket socket = new Socket ( AddressFamily . InterNetwork , SocketType . Stream , ProtocolType . Tcp ) ;
9898 socket . Connect ( endPoint ) ;
99- var connect = new ClientConnection ( socket ) ;
99+ ClientConnection connect = new ClientConnection ( socket ) ;
100100 connect . Receive ( ) ;
101101 return connect ;
102102 }
@@ -108,12 +108,12 @@ public void SendHandshake()
108108
109109 public Task SendHandshakeAsync ( )
110110 {
111- var e = Rsa . Encrypt ( _rc4 . streamKey ) ;
112- var data = new byte [ e . Length + 4 ] ;
113- Array . Copy ( ( Array ) e , ( int ) 0 , ( Array ) data , ( int ) 4 , ( int ) e . Length ) ;
111+ byte [ ] e = Rsa . Encrypt ( _rc4 . streamKey ) ;
112+ byte [ ] data = new byte [ e . Length + 4 ] ;
113+ Array . Copy ( e , 0 , data , 4 , e . Length ) ;
114114
115- var source = new TaskCompletionSource < IMessage > ( ) ;
116- EnqueueCompletionSource ( Commands . Welcome , source ) ;
115+ TaskCompletionSource < IMessage > source = new TaskCompletionSource < IMessage > ( ) ;
116+ EnqueueCompletionSource ( Commands . Welcome , source ) ;
117117
118118 base . Send ( data ) ;
119119 return source . Task ;
@@ -122,11 +122,11 @@ public Task SendHandshakeAsync()
122122 public event TcpConnectionEventHandler < IMessage > MessageReceived ;
123123 protected virtual void OnReceived ( string messageText )
124124 {
125- var message = Message . Parse ( messageText ) ;
126- MessageReceived ? . Invoke ( this , message ) ;
125+ Message message = Message . Parse ( messageText ) ;
126+ MessageReceived ? . Invoke ( this , message ) ;
127127
128128
129- var q = _commandQueue . GetOrDefault ( message . Command ) ;
129+ ConcurrentQueue < TaskCompletionSource < IMessage > > q = _commandQueue . GetOrDefault ( message . Command ) ;
130130 if ( q != null )
131131 {
132132 if ( q . TryDequeue ( out TaskCompletionSource < IMessage > source ) )
0 commit comments