{"id":49332,"library":"serve-socket","title":"ServeSocket","description":"A real-time WebSocket service for restaurant waiter coordination, built for Angular 15+ with TypeScript types included. Version 6.0.2 is stable and actively maintained. Integrates with MQTT 5+ for message brokering. Key differentiators: Angular-native dependency injection, automatic reconnection, and order lifecycle events.","status":"active","version":"6.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/apeex/serve-plus","tags":["javascript","typescript"],"install":[{"cmd":"npm install serve-socket","lang":"bash","label":"npm"},{"cmd":"yarn add serve-socket","lang":"bash","label":"yarn"},{"cmd":"pnpm add serve-socket","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides Angular HTTP client and common services","package":"@angular/common","optional":false},{"reason":"Required for Angular dependency injection and lifecycle","package":"@angular/core","optional":false},{"reason":"Used for MQTT protocol communication with the broker","package":"mqtt","optional":false}],"imports":[{"note":"Library is ESM-only and ships TypeScript declarations.","wrong":"const { ServeSocketService } = require('serve-socket');","symbol":"ServeSocketService","correct":"import { ServeSocketService } from 'serve-socket';"},{"note":"All types are exported from the main entry point.","wrong":"import { WaiterEvent } from 'serve-socket/models';","symbol":"WaiterEvent","correct":"import { WaiterEvent } from 'serve-socket';"},{"note":"Enum is re-exported from the root module.","wrong":"import { OrderStatus } from 'serve-socket/enums';","symbol":"OrderStatus","correct":"import { OrderStatus } from 'serve-socket';"},{"note":"Import the module directly from the package root for Angular usage.","wrong":"import { ServeSocketModule } from 'serve-socket/serve-socket.module';","symbol":"ServeSocketModule","correct":"import { ServeSocketModule } from 'serve-socket';"}],"quickstart":{"code":"import { NgModule } from '@angular/core';\nimport { BrowserModule } from '@angular/platform-browser';\nimport { ServeSocketModule } from 'serve-socket';\nimport { AppComponent } from './app.component';\n\n@NgModule({\n  declarations: [AppComponent],\n  imports: [\n    BrowserModule,\n    ServeSocketModule.forRoot({ brokerUrl: process.env['MQTT_BROKER'] ?? 'ws://localhost:9001' })\n  ],\n  bootstrap: [AppComponent]\n})\nexport class AppModule {}\n\nimport { Component, OnInit } from '@angular/core';\nimport { ServeSocketService, WaiterEvent } from 'serve-socket';\n\n@Component({\n  selector: 'app-waiter',\n  template: '<button (click)=\"callWaiter()\">Call Waiter</button>'\n})\nexport class WaiterComponent implements OnInit {\n  constructor(private serveSocket: ServeSocketService) {}\n\n  ngOnInit() {\n    this.serveSocket.on('order-ready', (event: WaiterEvent) => {\n      console.log('Order ready:', event.tableId);\n    });\n  }\n\n  callWaiter() {\n    this.serveSocket.emit('call-waiter', { tableId: 5 });\n  }\n}","lang":"typescript","description":"Demonstrates importing ServeSocketModule, configuring the MQTT broker, and using the service to emit and listen for WebSocket events."},"warnings":[{"fix":"Upgrade your project to Angular 15 or higher.","message":"Drop support for Angular <15: The library now requires @angular/core >=15.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Update mqtt in your package.json to >=5.0.0.","message":"MQTT version bump: peer dependency changed from mqtt@4.x to mqtt@5.x.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Replace calls to emitLocationUpdate with emitTableUpdate.","message":"The 'ServerSocketService.emitLocationUpdate' method is deprecated in favor of 'emitTableUpdate'","severity":"deprecated","affected_versions":">=6.0.0"},{"fix":"Use ServeSocketModule.forRoot() in AppModule imports only.","message":"Module must be imported with forRoot() when used in the root NgModule; using forChild() incorrectly may cause double service instantiation.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'15':15 '5':30 '6.0.2':21 'activ':25 'angular':14,37 'angular-n':36 'automat':41 'broker':33 'built':12 'coordin':11 'depend':39 'differenti':35 'event':46 'includ':19 'inject':40 'integr':27 'javascript':47 'key':34 'lifecycl':45 'maintain':26 'messag':32 'mqtt':29 'nativ':38 'order':44 'real':4 'real-tim':3 'reconnect':42 'restaur':9 'servesocket':1 'servic':7 'stabl':23 'time':5 'type':18 'typescript':17,48 'version':20 'waiter':10 'websocket':6","created_at":"2026-06-07T17:01:13.242094+00:00","updated_at":"2026-06-07T17:01:13.242094+00:00","problems":[{"fix":"npm install mqtt@>=5.0.0","cause":"Missing mqtt peer dependency","error":"Error: Can't resolve 'mqtt'"},{"fix":"Add ServeSocketModule.forRoot(...) to your root NgModule imports.","cause":"ServeSocketModule not imported or not configured via forRoot()","error":"NullInjectorError: No provider for ServeSocketService!"},{"fix":"Use emit('call-waiter', ...) instead of emitCallWaiter.","cause":"API changed; method renamed in v6","error":"Property 'emitCallWaiter' does not exist on type 'ServeSocketService'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/apeex/serve-plus#readme","github":"https://github.com/apeex/serve-plus","docs":null,"changelog":null,"pypi":null,"npm":"serve-socket","openapi_spec":null,"status_page":null,"smithery":null,"categories":["communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}