forked from bni/orbium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebSocket client and server beginnings
- Loading branch information
bni
committed
Mar 2, 2011
1 parent
6a70de8
commit c6d2cbd
Showing
4 changed files
with
133 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(function(orbium) { | ||
orbium.Client = function(url) { | ||
var socket = null; | ||
|
||
this.construct = function() { | ||
console.log("trying to connect."); | ||
socket = new WebSocket(url); | ||
socket.onopen = this.opened; | ||
socket.onmessage = this.received; | ||
}; | ||
|
||
this.opened = function() { | ||
console.log("connection established."); | ||
socket.send("well hello"); | ||
}; | ||
|
||
this.send = function(msg) { | ||
socket.send(msg); | ||
}; | ||
|
||
this.received = function(msg) { | ||
console.log("received: "+msg.data); | ||
}; | ||
|
||
var that = this; this.construct.apply(this, arguments); | ||
}; | ||
}(typeof window != "undefined" ? window.orbium = window.orbium || {} : orbium)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters