Skip to content

Issue Solved when client get just eventName #26

Open
@huseong

Description

@huseong

When I emit event that is consist of just event name in my node server
socket.emit('version')
Than issue occurs in client because of the parsing problem.
When I check the event using Debug.log()
It looks like ["version"] .
So I change Socket.cs code.
before

                    var seperateIndex = pkt.body.IndexOf(", ");

                    var seperatorLen = 2;
                    if (seperateIndex == -1) {
                        seperateIndex = pkt.body.IndexOf(',');
                        seperatorLen = 1;
                    }

                    var eventName = pkt.body.Substring(2, seperateIndex - 3);
                    if (!_handlers.ContainsKey(eventName)) {
                        Debug.LogWarningFormat("{0} event doesn't have a handler", eventName);
                        break;
                    }

after

                    int seperateIndex = pkt.body.IndexOf(", ");
                    int seperatorLen = 2;
                    if (seperateIndex == -1) {
                        seperateIndex = pkt.body.IndexOf(',');
                        if (seperateIndex == -1) {
                            seperateIndex = pkt.body.Length - 1;
                        }
                        seperatorLen = 1;
                    }
                    string eventName = pkt.body.Substring(2, seperateIndex - 3);
                    if (!_handlers.ContainsKey(eventName)) {
                        Debug.LogWarningFormat("{0} event doesn't have a handler", eventName);
                        break;
                    }
                    if (eventName.Length == pkt.body.Length - 4) {
                        _handlers[eventName]("");
                        break;
                    }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions