Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Fix namespace to use the same socket connection with multiple namespaces. #198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jbaez
Copy link

@jbaez jbaez commented Jul 8, 2014

The current namespace implementation was not ideal, it would create a new socket connection for each namespace.
In this PR the namespace was removed from SocketIO class.
To share the same socket connection with multiple namespaces the SocketIONamespace class can be used instead.

SocketIONamespace *socketNS  = [SocketIONamespace namespaceWithEndpoint:@"/endpoint" delegate:self];

Basically SocketIONamespace creates a SocketIO singleton which is reused by all SocketIONamespace instances. SocketIONamespace instances register themselves as a delegate of SocketIO.
SocketIO will send events/messages only to the matching namespace SocketIONamespace instance.

pd: SocketIO has an array of weak pointers for the namespaces delegates implemented with a NSPointerArray, which is available on iOS 6 and later.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants