MCPcopy Create free account
hub / github.com/SmingHub/Sming / sendNewMessage

Function sendNewMessage

samples/Websocket_Client/app/application.cpp:79–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79void sendNewMessage()
80{
81 if(!WifiStation.isConnected()) {
82 // Check if Esp8266 is connected to router
83 return;
84 }
85
86 if(messageCount >= MESSAGES_TO_SEND) {
87 if(sendBinary) {
88 Serial.println(_F("End Websocket client session"));
89 wsClient.close(); // clean disconnect.
90 return;
91 }
92
93 messageCount = 0;
94 sendBinary = true;
95 }
96
97 if(sendBinary) {
98 uint8_t buf[10];
99 os_get_random(buf, sizeof(buf));
100 buf[1] = messageCount;
101 m_printHex(_F("Sending websocket binary"), buf, sizeof(buf));
102 wsClient.sendBinary(buf, sizeof(buf));
103 } else {
104 String message = F("Hello ") + String(messageCount);
105 Serial << _F("Sending websocket message: ") << message << endl;
106 wsClient.sendString(message);
107 }
108
109 ++messageCount;
110 msgTimer.startOnce();
111}
112
113void STAGotIP(IpAddress ip, IpAddress mask, IpAddress gateway)
114{

Callers

nothing calls this directly

Calls 10

m_printHexFunction · 0.85
printlnMethod · 0.80
sendBinaryMethod · 0.80
startOnceMethod · 0.80
os_get_randomFunction · 0.50
FFunction · 0.50
StringClass · 0.50
isConnectedMethod · 0.45
closeMethod · 0.45
sendStringMethod · 0.45

Tested by

no test coverage detected