Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue Solved when client get just eventName #26

Open
huseong opened this issue Nov 20, 2017 · 1 comment
Open

Issue Solved when client get just eventName #26

huseong opened this issue Nov 20, 2017 · 1 comment
Assignees

Comments

@huseong
Copy link

huseong commented Nov 20, 2017

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;
                    }
@nhn nhn deleted a comment from ototot-dev Dec 7, 2017
@ppz0th
Copy link
Contributor

ppz0th commented Dec 7, 2017

@huseong Sorry for my late reply on your issue. Thanks to your report~ I'll check this and apply on develop branch. Or you can make Pull-Request to develop branch. This make me easy to apply your change on our code.

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

No branches or pull requests

2 participants