Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

changed to a much better repository layout

  • Loading branch information...
commit a12a1ef16d3c7afb776c65e4d821e0caaaa75903 1 parent 25130e3
William Harris authored
View
0  client/css/styles.css → example/client/css/styles.css
File renamed without changes
View
0  client/js/jquery.socket.io.js → example/client/js/jquery.socket.io.js
File renamed without changes
View
2  client/js/main.js → example/client/js/main.js
@@ -9,7 +9,7 @@ $(document).ready( function () {
});
- //the client is calling the client
+ //the server is calling the client
$(jqSH).bind('calling', function(event, message){
var messageContainer = $("div#message");
View
0  server-example/lib/node-socket-wrapper.js → example/server/lib/node-socket-wrapper.js
File renamed without changes
View
0  server-example/server.js → example/server/server.js
File renamed without changes
View
0  server-example/views/layout.jade → example/server/views/layout.jade
File renamed without changes
View
0  server-example/views/test.jade → example/server/views/test.jade
File renamed without changes
View
47 src/jquery.socket.io.js
@@ -0,0 +1,47 @@
+(function( $ ){
+
+ $.socketio = function() {
+
+ // Create SocketIO instance, connect
+ var socket = new io.Socket();
+ handler = {};
+
+ socket.connect();
+
+ // Add a connect listener
+ socket.on('connect',function() {
+ console.log('Client has connected to the server!');
+ });
+
+ socket.on('message', function(obj){
+
+ if('event' in obj) {
+ $(handler).trigger(obj.event, obj.data);
+ }
+
+ if(window.console) console.log('The '+ obj.event +' was fired.');
+ });
+
+
+ // Add a disconnect listener
+ socket.on('disconnect',function() {
+ console.log('The server has disconnected!');
+ });
+
+ handler._trigger = function(event, data) {
+ socket.send({"event" : event, "data" : data});
+ }
+
+ handler.GetTime = function() {
+ handler._trigger('getTime', '');
+ }
+
+ handler.sendEvent = function(ev,msg) {
+ handler._trigger(ev,msg);
+ }
+
+ return handler;
+
+ }
+
+})( jQuery );
Please sign in to comment.
Something went wrong with that request. Please try again.