use of org.ballerinalang.net.http.WebSocketServicesRegistry in project ballerina by ballerina-lang.
the class NonListeningRegister method execute.
@Override
public void execute(Context context) {
Service service = BLangConnectorSPIUtil.getServiceRegistered(context);
Struct serviceEndpoint = BLangConnectorSPIUtil.getConnectorEndpointStruct(context);
HTTPServicesRegistry httpServicesRegistry = getHttpServicesRegistry(serviceEndpoint);
WebSocketServicesRegistry webSocketServicesRegistry = getWebSocketServicesRegistry(serviceEndpoint);
// TODO: In HTTP to WebSocket upgrade register WebSocket service in WebSocketServiceRegistry
if (HttpConstants.HTTP_SERVICE_ENDPOINT_NAME.equals(service.getEndpointName())) {
httpServicesRegistry.registerService(service);
}
if (WebSocketConstants.WEBSOCKET_ENDPOINT_NAME.equals(service.getEndpointName())) {
WebSocketService webSocketService = new WebSocketService(service);
webSocketServicesRegistry.registerService(webSocketService);
}
context.setReturnValues();
}
use of org.ballerinalang.net.http.WebSocketServicesRegistry in project ballerina by ballerina-lang.
the class InitEndpoint method execute.
@Override
public void execute(Context context) {
try {
Struct serviceEndpoint = BLangConnectorSPIUtil.getConnectorEndpointStruct(context);
// Creating server connector
Struct serviceEndpointConfig = serviceEndpoint.getStructField(HttpConstants.SERVICE_ENDPOINT_CONFIG);
ListenerConfiguration listenerConfiguration = getListerConfig(serviceEndpointConfig);
ServerConnector httpServerConnector = HttpConnectionManager.getInstance().createHttpServerConnector(listenerConfiguration);
serviceEndpoint.addNativeData(HttpConstants.HTTP_SERVER_CONNECTOR, httpServerConnector);
// Adding service registries to native data
WebSocketServicesRegistry webSocketServicesRegistry = new WebSocketServicesRegistry();
HTTPServicesRegistry httpServicesRegistry = new HTTPServicesRegistry(webSocketServicesRegistry);
serviceEndpoint.addNativeData(HttpConstants.HTTP_SERVICE_REGISTRY, httpServicesRegistry);
serviceEndpoint.addNativeData(HttpConstants.WS_SERVICE_REGISTRY, webSocketServicesRegistry);
// set filters
setFilters(serviceEndpointConfig, serviceEndpoint);
context.setReturnValues((BValue) null);
} catch (Throwable throwable) {
BStruct errorStruct = HttpUtil.getHttpConnectorError(context, throwable);
context.setReturnValues(errorStruct);
}
}
use of org.ballerinalang.net.http.WebSocketServicesRegistry in project ballerina by ballerina-lang.
the class InitWebSubSubscriberServiceEndpoint method execute.
@Override
public void execute(Context context) {
Struct subscriberServiceEndpoint = BLangConnectorSPIUtil.getConnectorEndpointStruct(context);
Struct serviceEndpoint = ConnectorSPIModelHelper.createStruct((BStruct) ((BStruct) (subscriberServiceEndpoint.getVMValue())).getRefField(1));
WebSubServicesRegistry webSubServicesRegistry = new WebSubServicesRegistry(new WebSocketServicesRegistry());
serviceEndpoint.addNativeData(WebSubSubscriberConstants.WEBSUB_SERVICE_REGISTRY, webSubServicesRegistry);
context.setReturnValues();
}
use of org.ballerinalang.net.http.WebSocketServicesRegistry in project ballerina by ballerina-lang.
the class Register method execute.
@Override
public void execute(Context context) {
Service service = BLangConnectorSPIUtil.getServiceRegistered(context);
Struct serviceEndpoint = BLangConnectorSPIUtil.getConnectorEndpointStruct(context);
HTTPServicesRegistry httpServicesRegistry = getHttpServicesRegistry(serviceEndpoint);
WebSocketServicesRegistry webSocketServicesRegistry = getWebSocketServicesRegistry(serviceEndpoint);
// TODO: In HTTP to WebSocket upgrade register WebSocket service in WebSocketServiceRegistry
if (HttpConstants.HTTP_SERVICE_ENDPOINT_NAME.equals(service.getEndpointName())) {
httpServicesRegistry.registerService(service);
}
if (WebSocketConstants.WEBSOCKET_ENDPOINT_NAME.equals(service.getEndpointName())) {
WebSocketService webSocketService = new WebSocketService(service);
webSocketServicesRegistry.registerService(webSocketService);
}
if (!isConnectorStarted(serviceEndpoint)) {
startServerConnector(serviceEndpoint, httpServicesRegistry, webSocketServicesRegistry);
}
context.setReturnValues();
}
Aggregations