On Thu, Jan 14, 2010 at 4:02 AM, suraj soni <[email protected]> wrote:

> Thnx Manti,
>
> What do you mean by websocket is enabled? You mean on the extension side or
> the server side(java).
> If you mean the java server side, how do i enable it?
>
> I am having trouble in completing the handshake from the java server side.
> The server comes out of accept but it is not able to complete the handshake
> for the onopen() function in the extension to return.
>
> If you could just look at the following code :
>
> background.html ( in the extension )
> <script>
> chrome.windows.onCreated.addListener(function(Window)
> {
> console.log("Window is successfully created");
> });
> if ("WebSocket" in window) {
> console.log("Websockets are supported here ");
>  var ws = new WebSocket("ws://localhost:49731");
>  console.log("Web Socket created with the state "+ ws.readyState);
>  try {
>  ws.onopen=function(){
>  alert("Connection opened");};
>  }
>
>  catch (err) {
> console.log(err);
>  }
>  console.log("exiting with state as :"+ ws.readyState);
> }
> </script>
>
>
> this the code that i am writing for my java server :
>
> try{
> hearsay_socket = new ServerSocket(49731);
>  System.out.println("Waiting on Accept");
>  js_socket = hearsay_socket.accept();
>  System.out.println("Handling client at " +
>         js_socket.getInetAddress().getHostAddress() + " on port " +
>              js_socket.getPort());
> out = new PrintWriter(js_socket.getOutputStream(),true);
>  in = new BufferedReader(new
> InputStreamReader(js_socket.getInputStream()));
>  System.out.println("Web socket Accepted");
>  for(;;)
> {
>  bufferedData= in.readLine();
> System.out.println(bufferedData);
>  if(bufferedData.length()==0)
> {
>  System.out.println("Breaking");
>  break;
> }
>  }
> }
>  catch(UnknownHostException e)
> {
>  System.err.println("Have no information about the host : localhost");
>  System.exit(1);
> }
>  catch(IOException e)
> {
>  System.err.println("Couldn't establish communication");
>  }
>    handShake1 = "HTTP/1.1 101 Web Socket Protocol Handshake\r\n"+
>  "Upgrade: WebSocket\r\n"+
>  "Connection: Upgrade\r\n";
>  handShake2= "WebSocket-Origin:
> chrome-extension://jikhaebpllfkfacdccmeonpkpfcnldna\r\n"+
>  "WebSocket-Location:
> ws:/"+js_socket.getLocalAddress()+":"+js_socket.getLocalPort()+"\r\n\r\n";
>

ws:/ should be ws://
and js_socket.getLocalAddress() is really "localhost"?
I think this line can be: "WebSocket-Location:
ws://localhost:49731/\r\n\r\n" ?

-- 
ukai

 handShake2=handShake2.toLowerCase();
>  System.out.println(handShake2);
> byte[] bytes1=handShake1.getBytes("ASCII");
>  byte[] bytes2= handShake2.getBytes("ASCII");
>  out.print(bytes1);
> out.print(bytes2);
>
>
>
> Sorry for dumping the entire code here, but i think it would be better for
> others to catch the glitch in the program, if any.
>
> Regards
> Suraj Soni
>
> If U can solve ur problem, then what is need of worrying?
> If U cannot solve it, then what is the use of worrying.
>
>
> On Wed, Jan 13, 2010 at 1:48 PM, Manticore <[email protected]> wrote:
>
>> Hey,
>>
>> To answer your question if WebSocket is enabled - it is. See this blog
>> post
>> http://blog.chromium.org/2009/12/web-sockets-now-available-in-google.html
>>
>> Manticore
>>
>> On 13 Jan, 17:54, suraj soni <[email protected]> wrote:
>> > I am working on a Research Project  at the SUNY Stony Brook
>> > University.
>> >
>> > I am developing an extension which requires a two way communication
>> > channel, i.e. a TCP socket.
>> >
>> > My server would be a java backend server running on the local host
>> > and my client would of-course be a chrome extension.
>> >
>> > I am currently on a Windows m/c with Google Chrome version "4.0.288.1
>> > dev".
>> >
>> > Is it possible to establish such a communication link between the two
>> > using websockets? If yes then could anyone guide me to a link /
>> > example available.
>> >
>> > Also if websocket is not the answer to this, what should my approach
>> > be?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Chromium-extensions" group.
>> To post to this group, send email to [email protected]
>> .
>> To unsubscribe from this group, send email to
>> [email protected]<chromium-extensions%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/chromium-extensions?hl=en.
>>
>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Chromium-extensions" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<chromium-extensions%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/chromium-extensions?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=en.

Reply via email to