Skip to content

Commit

Permalink
Merge pull request cocos2d#2904 from edwardzhou/master
Browse files Browse the repository at this point in the history
closed cocos2d#2312: WebSocket url parse error for 'ws://domain.com/websocket' pattern
  • Loading branch information
James Chen committed Jun 19, 2013
2 parents f9cf8bd + 5077bf3 commit a8ae53b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions extensions/network/WebSocket.cpp
Expand Up @@ -281,7 +281,7 @@ bool WebSocket::init(const Delegate& delegate,
port = atoi(host.substr(pos+1, host.size()).c_str());
}

pos = host.find("/", pos);
pos = host.find("/", 0);
std::string path = "/";
if(pos >= 0){
path += host.substr(pos + 1, host.size());
Expand All @@ -290,14 +290,17 @@ bool WebSocket::init(const Delegate& delegate,
pos = host.find(":");
if(pos >= 0){
host.erase(pos, host.size());
}else if((pos = host.find("/"))>=0) {
host.erase(pos, host.size());
}


_host = host;
_port = port;
_path = path;
_SSLConnection = useSSL ? 1 : 0;

CCLOG("[WebSocket::init] _host: %s, _port: %d, _path: %s", _host.c_str(), _port, _path.c_str());

int protocolCount = 0;
if (protocols && protocols->size() > 0)
{
Expand Down

0 comments on commit a8ae53b

Please sign in to comment.