-
-
Notifications
You must be signed in to change notification settings - Fork 49
Namespaces
Gerasimos (Makis) Maropoulos edited this page Jul 1, 2019
·
4 revisions
We've already seen how to declare and connect to namespaces but details were missing. In this section you will learn how to disallow a client from connecting to a namespace and what a namespace really is.
Here is a list of what we mean by the word Namespaces
.
- Each connection can be connected to one or more namespaces.
- Namespaces should be static and should be declared in both server and client-side(clients can ignore some of the server's namespaces if not willing to connect to them).
- Client should connect to a namespace, even if its name is empty
""
. - Client and server are notified of each namespace connection and disconnection through their
OnNamespaceConnect, OnNamespaceConnected
andOnNamespaceDisconnect
built-in events. - Client can ask server to connect to a namespace.
- Server can ask client to connect to a namespace.
- Server and client can accept or decline the client or server's connection to a namespace through their
OnNamespaceConnect -> return err != nil
. - Client can ask server to disconnect from a namespace.
- Server can forcely disconnect a client from a namespace.
// blocks until connect in both sides.
nsConn, err := conn.Connect(ctx, "namespace")
nsConn.Emit("event", body)
// nsConn.Conn.Write(neffos.Message{
// Namespace: "namespace",
// Event: "event",
// Body: body,
// })
nsConn.Disconnect(ctx)
Continue by reading about Rooms.
Home | About | Project | Getting Started | Technical Docs | Copyright © 2019-2023 Gerasimos Maropoulos. Documentation terms of use.