-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Commit some added safety and logging
- Loading branch information
Showing
4 changed files
with
120 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
class ConnectionHealth{ | ||
DateTime creation = DateTime.now(); | ||
int pingsSent = 0; | ||
int pongsReceived = 0; | ||
DateTime? lastMessageSent; | ||
DateTime? lastMessageReceived; | ||
int messageSent = 0; | ||
int messageRecieved = 0; | ||
|
||
logPing(){ | ||
pingsSent ++; | ||
lastMessageSent = DateTime.now(); | ||
} | ||
|
||
logPong(){ | ||
pongsReceived ++; | ||
lastMessageReceived = DateTime.now(); | ||
} | ||
|
||
logMessageSent(){ | ||
messageSent ++; | ||
lastMessageSent = DateTime.now(); | ||
} | ||
|
||
logMessageReceived(){ | ||
messageRecieved ++; | ||
lastMessageReceived = DateTime.now(); | ||
} | ||
|
||
@override | ||
String toString() { | ||
return "Created: $creation Sent: $lastMessageSent Recieved: $lastMessageReceived pings $pongsReceived/$pingsSent messages $messageSent | $messageRecieved"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters