Skip to content

Instantly share code, notes, and snippets.

View kalaiyarasiganeshalingam's full-sized avatar

Kalaiyarasi Ganeshalingam kalaiyarasiganeshalingam

View GitHub Profile
pipeline {
agent any
tools {
maven "mvn"
}
environment {
DOCKER_REGISTRY = 'JFROG_ARTIFACTORY_URL'
ARTIFACTORY_USERNAME= 'JFROG_ARTIFACTORY_USERNAME'
import ballerina/http;
import ballerina/log;
import ballerina/io;
// Annotations specifying the webSocket service.
@http:WebSocketServiceConfig {
path: "/websocket"
}
// Define the backend service with port 15300.
import ballerina/io;
import ballerina/http;
public function main() {
http:WebSocketClient wsClientEp = new("ws://localhost:9090/websocket", config = {callbackService: ClientService});
checkpanic wsClientEp->pushText("hello");
}
service ClientService =@http:WebSocketServiceConfig {} service {
resource function onText(http:WebSocketClient conn, string text, boolean finalFrame) {
@kalaiyarasiganeshalingam
kalaiyarasiganeshalingam / server_with_single_resource.bal
Last active October 5, 2020 07:31
server with a single resource
import ballerina/http;
import ballerina/log;
@http:WebSocketServiceConfig {
path: "/hello/ws"
}
service basic on new http:Listener(21005) {
// The resource is triggered after a successful client connection
resource function onOpen(http:WebSocketCaller caller) {
log:printInfo("connection open");
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 {