WebSocket4Net and PhoneGap

Jun 12, 2012 at 10:08 PM

Has anybody got this working with PhoneGap and Windows Phone?

I have websockets working with IOS and Android using native or other lirbraries, but having a slow time of it with this one.

Any examples out there?

Coordinator
Jun 13, 2012 at 2:16 AM

I can answer you in many cases:

For PhoneGap in IOS: because of Websocket is supported by latest version Safari, so you have nothing to do for it

For PhoneGap in Android: because the default  browser in Android doesn't support WebSocket yet, so you need to have a Java websocket client working as PhoneGap plugin to support websocket

For WindowsPhone: there is already many open source .NET websocket client providing WindowsPhone assemblies, like WebSocket4Net.

What do you mean "having a slow time of it with this one"?

Jun 13, 2012 at 11:34 PM

Like I said - I have web socket clients working with Phone Gap in IOS and Android.

I am trying to get it working in Windows Phone and this library seems to come highly recommended and I am trying to wrap it up as a plugin in Phone Gap.

I am having problems just getting this working in my Visual Studio 2010 Express for Windows Phone so I can test it against my Web Socket Server and cannot seem to find any sample projects anywhere so I can just test this.

Any help would be appreciated.

Shawn

 

Coordinator
Jun 14, 2012 at 1:24 AM
The demo code is on homepage. Does it help?

Sent from my Windows Phone

From: shawnbigger
Sent: 6/14/2012 7:34 AM
To: kerry-jiang@hotmail.com
Subject: Re: WebSocket4Net and PhoneGap [websocket4net:359372]

From: shawnbigger

Like I said - I have web socket clients working with Phone Gap in IOS and Android.

I am trying to get it working in Windows Phone and this library seems to come highly recommended and I am trying to wrap it up as a plugin in Phone Gap.

I am having problems just getting this working in my Visual Studio 2010 Express for Windows Phone so I can test it against my Web Socket Server and cannot seem to find any sample projects anywhere so I can just test this.

Any help would be appreciated.

Shawn

Jun 14, 2012 at 2:00 AM

Get allot of errors with the code snippet and can't get it to compile.

If there is a visual studio project sample that would be great to see what I am doing wrong.

Coordinator
Jun 14, 2012 at 2:08 AM

What's the error?

Jun 14, 2012 at 5:14 AM

I am working with Visual Studio Express for Windows Mobile.

Setting up a project of a single screen application with 3 buttons, connect, send, disconnect.

When I try to create an instance of WebSocket using the following code get this error.

_message = "Could not load type 'WebSocket4Net.WebSocket' from assembly 'WebSocket4Net, Version=0.7.0.0, Culture=neutral, PublicKeyToken=EB4E154B696BF72A'."

HRESULT = -2146233054

Here is the code

using

System;

using

System.Collections.Generic;

using

System.Linq;

using

System.Net;

using

System.Windows;

using

System.Windows.Controls;

using

System.Windows.Documents;

using

System.Windows.Input;

using

System.Windows.Media;

using

System.Windows.Media.Animation;

using

System.Windows.Shapes;

using

Microsoft.Phone.Controls;

using

WebSocket4Net;

namespace

PhoneApp2

{

public partial class MainPage : PhoneApplicationPage

{ 

// Constructor

public MainPage()

{

InitializeComponent();

}

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)

{

}

private void Connect_Click(object sender, RoutedEventArgs e)

{

try

{

WebSocket ws = new WebSocket("ws://192.168.0.7:20000/WebSocket" );

}

catch (Exception ex)

{

var msg = MessageBox.Show(ex.Message);

}

} 

private void Send_Click(object sender, RoutedEventArgs e)

{

var msg = MessageBox.Show("Send"

);

} 

private void Disconnect_Click(object sender, RoutedEventArgs e)

{

var msg = MessageBox.Show("Disconnect");

}

}

}

Coordinator
Jun 14, 2012 at 5:28 AM

Did you reference current assembly of WebSocket4Net, don't use .NET, Mono and SL version, just use the one in SL40-WindowsPhone71.

Could you mail me redirecly? I can give you a sample which can pass compiling.

Jun 14, 2012 at 5:40 AM

I sent you an email through contact coordinator

Jun 21, 2012 at 8:37 AM
Edited Jun 21, 2012 at 1:36 PM

Hi Shawn, Kerry,

I came here looking for the exact same thing. Have any of you had any success using WebSocket4Net with Cordova/PhoneGap, or even building a plugin?

Thanks.