Example #1
0
        public Namespace NS(string name)
        {
            if (namespaces.ContainsKey(name))
            {
                return(namespaces[name]);
            }

            var newNamespace = new Namespace(name, this);

            namespaces[name] = newNamespace;
            SIO_Packet p = new SIO_Packet(SIO_Packet.PacketType.CONNECT);

            p.Namespace = name;
            Send(p.Encode());
            return(newNamespace);
        }
        public void Emit(string eventName, IJsonValue args, AckCallback ackCallback)
        {
            SIO_Packet p = new SIO_Packet(SIO_Packet.PacketType.EVENT);

            p.Namespace = Name;

            if (args.ValueType == JsonValueType.Array)
            {
                args.GetArray().Insert(0, JsonValue.CreateStringValue(eventName));
                p.Data = args;
            }
            else
            {
                var data = new JsonArray();
                data.Add(JsonValue.CreateStringValue(eventName));
                data.Add(args);
                p.Data = data;
            }

            client.Send(p.Encode());
        }