axmol/cocos/network/SocketIO.h

199 lines
6.4 KiB
C
Raw Normal View History

Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
/****************************************************************************
Copyright (c) 2013 Chris Hannon http://www.channon.us
Copyright (c) 2013-2014 Chukong Technologies Inc.
2014-03-24 17:58:35 +08:00
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
2014-03-24 17:58:35 +08:00
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
2014-03-24 17:58:35 +08:00
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*based on the SocketIO library created by LearnBoost at http://socket.io
*using spec version 1 found at https://github.com/LearnBoost/socket.io-spec
Usage is described below, a full working example can be found in TestCpp under ExtionsTest/NetworkTest/SocketIOTest
creating a new connection to a socket.io server running at localhost:3000
2014-03-24 17:58:35 +08:00
SIOClient *client = SocketIO::connect(*delegate, "ws://localhost:3000");
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
the connection process will begin and if successful delegate::onOpen will be called
if the connection process results in an error, delegate::onError will be called with the err msg
sending a message to the server
2014-03-24 17:58:35 +08:00
client->send("Hello!");
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
emitting an event to be handled by the server, argument json formatting is up to you
2014-03-24 17:58:35 +08:00
client->emit("eventname", "[{\"arg\":\"value\"}]");
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
registering an event callback, target should be a member function in a subclass of SIODelegate
CC_CALLBACK_2 is used to wrap the callback with std::bind and store as an SIOEvent
2014-03-24 17:58:35 +08:00
client->on("eventname", CC_CALLBACK_2(TargetClass::targetfunc, *targetclass_instance));
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
event target function should match this pattern, *this pointer will be made available
2014-03-24 17:58:35 +08:00
void TargetClass::targetfunc(SIOClient *, const std::string&)
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
disconnect from the endpoint by calling disconnect(), onClose will be called on the delegate once complete
in the onClose method the pointer should be set to NULL or used to connect to a new endpoint
2014-03-24 17:58:35 +08:00
client->disconnect();
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
****************************************************************************/
#ifndef __CC_SOCKETIO_H__
#define __CC_SOCKETIO_H__
#include "CCPlatformMacros.h"
#include "CCMap.h"
#include <string>
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
2014-01-02 16:25:35 +08:00
NS_CC_BEGIN
namespace network {
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
//forward declarations
class SIOClientImpl;
class SIOClient;
/**
* @brief Singleton and wrapper class to provide static creation method as well as registry of all sockets
*/
class SocketIO
{
public:
2014-03-24 17:58:35 +08:00
static SocketIO* getInstance();
static void destroyInstance();
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
2014-03-24 17:58:35 +08:00
/**
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
* @brief The delegate class to process socket.io events
*/
2014-03-24 17:58:35 +08:00
class SIODelegate
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
{
public:
virtual ~SIODelegate() {}
2014-03-24 17:58:35 +08:00
virtual void onConnect(SIOClient* client) = 0;
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
virtual void onMessage(SIOClient* client, const std::string& data) = 0;
virtual void onClose(SIOClient* client) = 0;
virtual void onError(SIOClient* client, const std::string& data) = 0;
2014-03-24 17:58:35 +08:00
virtual void fireEventToScript(SIOClient* client, const std::string& eventName, const std::string& data) { CCLOG("SIODelegate event '%s' fired with data: %s", eventName.c_str(), data.c_str()); };
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
};
2014-03-24 17:58:35 +08:00
/**
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
* @brief Static client creation method, similar to socketio.connect(uri) in JS
* @param delegate The delegate which want to receive events from the socket.io client
* @param uri The URI of the socket.io server
* @return An initialized SIOClient if connected successfully, otherwise NULL
*/
2014-03-24 17:58:35 +08:00
static SIOClient* connect(const std::string& uri, SocketIO::SIODelegate& delegate);
CC_DEPRECATED_ATTRIBUTE static SIOClient* connect(SocketIO::SIODelegate& delegate, const std::string& uri);
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
private:
SocketIO();
2014-03-24 17:58:35 +08:00
virtual ~SocketIO(void);
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
2014-03-24 17:58:35 +08:00
static SocketIO *_inst;
2014-03-24 17:58:35 +08:00
cocos2d::Map<std::string, SIOClientImpl*> _sockets;
2014-03-24 17:58:35 +08:00
SIOClientImpl* getSocket(const std::string& uri);
void addSocket(const std::string& uri, SIOClientImpl* socket);
void removeSocket(const std::string& uri);
friend class SIOClientImpl;
private:
CC_DISALLOW_COPY_AND_ASSIGN(SocketIO)
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
};
//c++11 style callbacks entities will be created using CC_CALLBACK (which uses std::bind)
typedef std::function<void(SIOClient*, const std::string&)> SIOEvent;
//c++11 map to callbacks
typedef std::unordered_map<std::string, SIOEvent> EventRegistry;
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
/**
* @brief A single connection to a socket.io endpoint
*/
class SIOClient
2014-03-24 17:58:35 +08:00
: public cocos2d::Ref
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
{
private:
2014-03-24 17:58:35 +08:00
int _port;
std::string _host, _path, _tag;
bool _connected;
SIOClientImpl* _socket;
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
2014-03-24 17:58:35 +08:00
SocketIO::SIODelegate* _delegate;
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
2014-03-24 17:58:35 +08:00
EventRegistry _eventRegistry;
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
2014-03-24 17:58:35 +08:00
void fireEvent(const std::string& eventName, const std::string& data);
2014-03-24 17:58:35 +08:00
void onOpen();
void onConnect();
void receivedDisconnect();
2014-03-24 17:58:35 +08:00
friend class SIOClientImpl;
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
public:
2014-03-24 17:58:35 +08:00
SIOClient(const std::string& host, int port, const std::string& path, SIOClientImpl* impl, SocketIO::SIODelegate& delegate);
virtual ~SIOClient(void);
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
2014-03-24 17:58:35 +08:00
/**
* @brief Returns the delegate for the client
*/
2014-03-24 17:58:35 +08:00
SocketIO::SIODelegate* getDelegate() { return _delegate; };
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
2014-03-24 17:58:35 +08:00
/**
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
* @brief Disconnect from the endpoint, onClose will be called on the delegate when comlpete
*/
2014-03-24 17:58:35 +08:00
void disconnect();
/**
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
* @brief Send a message to the socket.io server
*/
2014-03-24 17:58:35 +08:00
void send(std::string s);
/**
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
* @brief The delegate class to process socket.io events
*/
2014-03-24 17:58:35 +08:00
void emit(std::string eventname, std::string args);
/**
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
* @brief Used to resgister a socket.io event callback
2014-03-24 17:58:35 +08:00
* Event argument should be passed using CC_CALLBACK2(&Base::function, this)
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
*/
2014-03-24 17:58:35 +08:00
void on(const std::string& eventName, SIOEvent e);
inline void setTag(const char* tag)
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
{
_tag = tag;
};
2014-03-24 17:58:35 +08:00
inline const char* getTag()
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
{
return _tag.c_str();
};
};
}
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
2014-01-02 16:25:35 +08:00
NS_CC_END
Implements a socket.io client extension, adds a test case and updates the android makefiles. Contains the following tasks: -initial socket.io extension commit -sioclientimpl subclasses websocket:delegate to respond to websocket events -implement static connect methods and basic client creation -move SocketIO class files into correct extension folder (network) -create SocketIO test in TestCpp -update project references -add missing static modifier to connect method -implement basic test methods -update extensions tests with SocketIO test entry -implement basic handshake and opensocket methods for SocketIO -add Delegate class to handle callbacks, implement virtual Delegate methods in test -implement socket and client registries for lookup when connecting to hosts and endpoints -connect delegate onOpen method by separating impl creation from connection -update test to demonstrate onOpen callback -create send and emit methods, move SIOClient into header file, add send and emit methods to test -implement basic socket.io message parsing -improve logging for events and messages -add logic to pull event name from payload -schedule heartbeat to keep connection alive, scheduled for 90% of the heartbeat interval from the server for safety -add onConnect handler to to catch socket.io onconnect vs websocket onopen -add disconnect and disconnectFromEndpoint methods to properly disconnect and destroy objects -modify SIOClientImpl to track _uri for easier lookup in registries -connect handler for onMessage to message event from socket.io, modify onError handler to take a string instead of WebSocket error code -create SIOEvent callback type, implement event registry in clients, add test for event registration and callback -update SIOEvent to use std::function and c++11, utilize cocos2d CC_CALLBACK method to bind selectors, this ensures that the *this reference is properly passed -check for connect before sending or emitting in the client, cleanup some codes -change connect logic to reuse existing socket connections instead of opening a new one -implements get and set Tag methods for clients for easy reference -improve endpoint handling, add endpoint tests to test layer -additional error handling within socket disconnect error and failure to open connection -fixes extracting endpoint from socket.io messages (in cases of the connect message, where there is 1 less colon for the connect message to the default namespace). Also fixes connecting to the default namespace "/" in the connectToEndpoint method -add disconnect and onClose handlers to client so that onClose is called in the delegate -add disconnect test methods to test layers -change c-style casts to static_casts when using a CCDICT_FOREACH -remove some unneeded namespace completion -add usage documentation -add handling for disconnect from server, cleanup some codes -update comments and documentation in the socketiotest -update includes so the NDK doesn't complain when compiling with c++11 -add socketio.cpp and test.cpp to the android makefiles -update test URL to my public server, test script can also be found in my repo at https://github.com/hannon235/socket.io-testserver.git Signed-off-by: Chris Hannon <himynameschris@gmail.com>
2013-06-26 10:40:01 +08:00
#endif /* defined(__CC_JSB_SOCKETIO_H__) */