Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently May 17th, 2024, 12:02 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Javascript Websocket
PostPosted: February 13th, 2015, 12:34 pm 
Offline

Joined: August 23rd, 2011, 11:36 am
Posts: 10
Hi all.
Complete JavaScript newbie here :shock: never done any scripting before.
Trying to add a Websocket function to a HTML5. Added a button with left click action and added the javascript:

ws = new WebSocket("ws://localhost:7890")
packet = new Uint8Array([ 0,0,0,0, 255,0,0, 0,255,0, 0,0,255 ]);
ws.send(packet.buffer)
ws.send(packet.buffer)

It's supposed to send RGB led data to the server running on my machine, but needless to say press the button and nothing happens.
I know I'm missing something (probably a lot!) and could do with a few pointers.
Thanks


For this message hawksey has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Javascript Websocket
PostPosted: February 13th, 2015, 3:23 pm 
Offline
User avatar

Joined: October 25th, 2004, 10:33 am
Posts: 257
Location: UK
Opus: Pro 8
OS: Windows 7 Professional x64
System: Dell XPS15 i7x4 2.1Ghz 6GB 128GB SSD
Are you running the HTML via your webserver? I.e. not using file://


For this message Dave Emberton has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Javascript Websocket
PostPosted: February 13th, 2015, 3:55 pm 
Offline

Joined: August 23rd, 2011, 11:36 am
Posts: 10
The generated Html5 page is running locally (in chrome) on the same machine the websocket server is running. Server part tested and working fine.


For this message hawksey has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Javascript Websocket
PostPosted: February 13th, 2015, 4:29 pm 
Offline
User avatar

Joined: October 25th, 2004, 10:33 am
Posts: 257
Location: UK
Opus: Pro 8
OS: Windows 7 Professional x64
System: Dell XPS15 i7x4 2.1Ghz 6GB 128GB SSD
I don't know what you mean by that. You need to be running your webpage from the server as in http://localhost/whatever.htm - the same server you're connecting to with websockets. If you're running it as a local file (which is what the Opus test will do), then websockets won't work.


For this message Dave Emberton has been thanked by : mackavi


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group