Skip to content

Instantly share code, notes, and snippets.

@kalaiyarasiganeshalingam
Last active September 15, 2020 08:20
Show Gist options
  • Select an option

  • Save kalaiyarasiganeshalingam/c78a3bc886bf239b17ec8c8d6fcc5ed5 to your computer and use it in GitHub Desktop.

Select an option

Save kalaiyarasiganeshalingam/c78a3bc886bf239b17ec8c8d6fcc5ed5 to your computer and use it in GitHub Desktop.
import ballerina/http;
import ballerina/io;
public function main() {
http:WebSocketClient wsClientEp = new("ws://echo.websocket.org",
config = {callbackService: ClientService});
checkpanic wsClientEp->pushText("hello");
}
service ClientService =@http:WebSocketServiceConfig {} service {
//This resource is triggered when a new text frame is received from the server.
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