Created
August 27, 2019 08:20
-
-
Save riyafa/984d314ecee9600ca71925732e2023c4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import ballerina/http; | |
import ballerina/io; | |
import ballerina/log; | |
public function main() { | |
http:WebSocketClient wsClientEp = new("ws://localhost:9090/ws/xyz/Mawanella?age=26", | |
config = {callbackService: ClientService, customHeaders:{"X-name":"Riyafa"}, subProtocols:["xml"]}); | |
var err = wsClientEp->pushText("hello"); | |
if (err is error) { | |
log:printError("Error in sending text", err = err); | |
} | |
} | |
service ClientService =@http:WebSocketServiceConfig {} service { | |
resource function onText(http:WebSocketClient conn, string text, boolean finalFrame) { | |
io:println(text); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment