Merge pull request #13953 from himynameschris/fix-socketio

Fix socketio to work with servers v1.0+
This commit is contained in:
pandamicro 2015-09-20 23:15:27 +08:00
commit fa9afd6c2b
2 changed files with 7 additions and 7 deletions

View File

@ -84,7 +84,7 @@ protected:
std::string _name;//event name
std::vector<std::string> _args;//we will be using a vector of strings to store multiple data
std::string _endpoint;//
std::string _endpointseperator;//socket.io 1.x requires a ',' between endpoint and payload
std::string _endpointseparator;//socket.io 1.x requires a ',' between endpoint and payload
std::string _type;//message type
std::string _separator;//for stringify the object
std::vector<std::string> _types;//types of messages
@ -101,7 +101,7 @@ private:
std::vector<std::string> _typesMessage;
};
SocketIOPacket::SocketIOPacket() :_separator(":")
SocketIOPacket::SocketIOPacket() :_separator(":"), _endpointseparator("")
{
_types.push_back("disconnect");
_types.push_back("connect");
@ -149,7 +149,7 @@ std::string SocketIOPacket::toString()const
// Add the endpoint for the namespace to be used if not the default namespace "" or "/", and as long as it is not an ACK, heartbeat, or disconnect packet
if (_endpoint != "/" && _endpoint != "" && _type != "ack" && _type != "heartbeat" && _type != "disconnect") {
encoded << _endpoint << _endpointseperator;
encoded << _endpoint << _endpointseparator;
}
encoded << this->_separator;
@ -230,8 +230,8 @@ std::string SocketIOPacket::stringify()const
SocketIOPacketV10x::SocketIOPacketV10x()
{
_separator = ":";
_endpointseperator = ",";
_separator = "";
_endpointseparator = ",";
_types.push_back("disconnected");
_types.push_back("connected");
_types.push_back("heartbeat");

View File

@ -195,7 +195,7 @@ void SocketIOTest::closedSocketAction(network::SIOClient* client)
void SocketIOTest::onMenuSIOClientClicked(cocos2d::Ref *sender)
{
//create a client by using this static method, url does not need to contain the protocol
_sioClient = SocketIO::connect("ws://dev.channon.us:3010", *this);
_sioClient = SocketIO::connect("ws://localhost:3010", *this);
//you may set a tag for the client for reference in callbacks
_sioClient->setTag("Test Client");
@ -212,7 +212,7 @@ void SocketIOTest::onMenuSIOClientClicked(cocos2d::Ref *sender)
void SocketIOTest::onMenuSIOEndpointClicked(cocos2d::Ref *sender)
{
//repeat the same connection steps for the namespace "testpoint"
_sioEndpoint = SocketIO::connect("ws://dev.channon.us:3010/testpoint", *this);
_sioEndpoint = SocketIO::connect("ws://localhost:3010/testpoint", *this);
//a tag to differentiate in shared callbacks
_sioEndpoint->setTag("Test Endpoint");