vanan08 / unitt

Automatically exported from code.google.com/p/unitt
0 stars 0 forks source link

How to use Cookie in WebSocketConnectConfig #55

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
I am trying to use session cookie with WebSocketConnectConfig but unable to 
succeed in communicating with my websocket, please advice me how to use Session 
cookie on each login with UnittSocketClient library for iOS.
2.
3.

What is the expected output? What do you see instead?

(id)init
{
self = [super init];
if (self)
{
//make sure to use the right url, it must point to your specific web socket 
endpoint or the handshake will fail
//create a connect config and set all our info here

NSLog(@"Socket Cookie %@",[[NSUserDefaults standardUserDefaults] 
stringForKey:@"cookie"]);

struct utsname info;
uname(&info);
WebSocketConnectConfig *config = [WebSocketConnectConfig 
configWithURLString:@"ws://mysocketUrl/socket"
                                                                      origin:nil
                                                                   protocols:nil
                                                                 tlsSettings:nil
                                                                     headers:[@[[HandshakeHeader headerWithValue:[NSString stringWithFormat:@"session=%@",[[NSUserDefaults standardUserDefaults] stringForKey:@"cookie"]] forKey:@"Cookie"]
                                                                                                      ] mutableCopy]
                                                           verifySecurityKey:YES
                                                                  extensions:nil];

//[WebSocketConnectConfig 
configWithURLString:@"ws://localhost:8080/testws/ws/test" origin:nil 
protocols:nil tlsSettings:nil headers:nil verifySecurityKey:YES extensions:nil 
];
config.closeTimeout = 15.0;
config.keepAlive = 15.0; //sends a ws ping every 15s to keep socket alive

//setup dispatch queue for delegate logic (not required, the websocket will 
create its own if not supplied)
dispatch_queue_t delegateQueue = dispatch_queue_create("myWebSocketQueue", 
NULL);

//open using the connect config, it will be populated with server info, such as 
selected protocol/etc
ws = [[WebSocket webSocketWithConfig:config queue:delegateQueue 
delegate:self]retain];

//release queue, it is retained by the web socket
dispatch_release(delegateQueue);
}
return self;
}

What version of the product are you using? On what operating system?

1.0.0.zip

Please provide any additional information below.

Unable to communicate and send Data to websocket

Original issue reported on code.google.com by catali...@gmail.com on 9 Jun 2013 at 4:42