@@ -193,7 +193,8 @@ static void Main(string[] args)
193193 serverState = ServerState . Running ;
194194
195195 //Keep this last!
196- runCallback ( ) ;
196+ if ( config . enableCallback )
197+ runCallback ( ) ;
197198 }
198199
199200 public static void crashMonitor ( )
@@ -394,33 +395,28 @@ public static void runCallback()
394395 {
395396 while ( true )
396397 {
397- if ( config . enableCallback )
398+ logInfo ( "Sending callback data to master server." ) ;
399+ try
398400 {
399- logInfo ( "Sending callback data to master server." ) ;
400-
401- try
402- {
403- var httpWebRequest = ( HttpWebRequest ) WebRequest . Create ( "http://callback.avilance.com/" ) ;
404- httpWebRequest . ContentType = "application/x-www-form-urlencoded" ;
405- httpWebRequest . Method = "POST" ;
406-
407- using ( var streamWriter = new StreamWriter ( httpWebRequest . GetRequestStream ( ) ) )
408- {
409- string json = "json={\" version\" :\" " + VersionNum + "\" ," +
410- "\" protocol\" :\" " + ProtocolVersion + "\" ," +
411- "\" mono\" :\" " + IsMono + "\" ," +
412- "\" proxyPort\" :\" " + config . proxyPort + "\" ," +
413- "\" maxSlots\" :\" " + config . maxClients + "\" ," +
414- "\" clientCount\" :\" " + clientCount + "\" }" ;
415-
416- streamWriter . Write ( json ) ;
417- streamWriter . Flush ( ) ;
418- }
419- }
420- catch ( Exception e )
421- {
422- logDebug ( "Callback" , e . ToString ( ) ) ;
423- }
401+ string json = "json={\" version\" :\" " + VersionNum + "\" ," +
402+ "\" protocol\" :\" " + ProtocolVersion + "\" ," +
403+ "\" mono\" :\" " + IsMono + "\" ," +
404+ "\" proxyPort\" :\" " + config . proxyPort + "\" ," +
405+ "\" maxSlots\" :\" " + config . maxClients + "\" ," +
406+ "\" clientCount\" :\" " + clientCount + "\" }" ;
407+ byte [ ] buffer = Encoding . UTF8 . GetBytes ( json ) ;
408+
409+ WebRequest request = WebRequest . Create ( "http://callback.avilance.com/" ) ;
410+ request . ContentType = "application/x-www-form-urlencoded" ;
411+ request . Method = "POST" ;
412+ request . ContentLength = buffer . Length ;
413+ Stream streamWriter = request . GetRequestStream ( ) ;
414+ streamWriter . Write ( buffer , 0 , buffer . Length ) ;
415+ streamWriter . Close ( ) ;
416+ }
417+ catch ( Exception e )
418+ {
419+ logDebug ( "Callback" , e . ToString ( ) ) ;
424420 }
425421 Thread . Sleep ( 1000 * 60 * 15 ) ;
426422 }
0 commit comments