Create a new service instance.
NgZone instance
Service configuration
Is the socket currently connected
Observable of connection state changes, emits true when connected and false when disconnected
The echo instance, can be used to implement any custom requirements outside of this service (remember to include NgZone.run calls)
Observable of raw events of the underlying connection
The socket ID
Join a channel of specified name and type.
The name of the channel to join
The type of channel to join
The instance for chaining
Listen for users joining the specified presence channel.
The name of the channel
An observable that emits the user when he joins the specified channel
Leave a channel of the specified name.
The name of the channel to leave
The instance for chaining
Listen for users leaving the specified presence channel.
The name of the channel
An observable that emits the user when he leaves the specified channel
Listen for events on the specified channel.
The name of the channel
The name of the event
An observable that emits the event data of the specified event when it arrives
Listen for client sent events (whispers) on the specified private or presence channel channel.
The name of the channel
The name of the event
An observable that emits the whisper data of the specified event when it arrives
Set authentication data and connect to and start listening for notifications on the users private channel
Authentication headers to send when talking to the service
The current user's id
The instance for chaining
Clear authentication data and close any presence or private channels.
The instance for chaining
Listen for notifications on the users private channel.
The type of notification to listen for or *
for any
Optional a different channel to receive notifications on
An observable that emits the notification of the specified type when it arrives
Listen for user list updates on the specified presence channel.
The name of the channel
An observable that emits the initial user list as soon as it's available
Send a client event to the specified presence or private channel (whisper).
The name of the channel
The name of the event
The payload for the event
The instance for chaining
The service class, use this as something like (or use the AngularLaravelEchoModule.forRoot method):
export const echoConfig: SocketIoEchoConfig = { userModel: 'App.User', notificationNamespace: 'App\\Notifications', options: { broadcaster: 'socket.io', host: window.location.hostname + ':6001' } } @NgModule({ ... providers: [ ... EchoService, { provide: ECHO_CONFIG, useValue: echoConfig } ... ] ... })
and import it in your component as
@Component({ ... }) export class ExampleComponent { constructor(echoService: EchoService) { } }