Skip to content
Browse files

Fix #11 Cannot specify WebSocketStompMock

This var was a hack to be able to test the lib using a mock stomp web
server.
Replace it by a variable "WebSocketClass" inside the Stomp object.

To use another WebSocket implementation than the one provided by the Web
browser, you can now specify:

Stomp.WebSocketClass = SockJS;
client = Stomp.client(url)
  • Loading branch information...
1 parent d1f6006 commit 475171878bf9de28c20a5c4d4cf4e5469b83d23f @jmesnil committed Jun 5, 2012
Showing with 6 additions and 8 deletions.
  1. +4 −6 dist/stomp.js
  2. +2 −2 src/stomp.coffee
View
10 dist/stomp.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.1
+// Generated by CoffeeScript 1.3.3
/*
Copyright (C) 2010 Jeff Mesnil -- http://jmesnil.net/
@@ -7,7 +7,7 @@ Copyright (C) 2012 FuseSource, Inc. -- http://fusesource.com
(function() {
- var Client, Stomp, WebSocketStompMock,
+ var Client, Stomp,
__hasProp = {}.hasOwnProperty;
Stomp = {
@@ -93,8 +93,6 @@ Copyright (C) 2012 FuseSource, Inc. -- http://fusesource.com
Client = (function() {
- Client.name = 'Client';
-
function Client(url) {
this.url = url;
this.counter = 0;
@@ -117,7 +115,7 @@ Copyright (C) 2012 FuseSource, Inc. -- http://fusesource.com
if (typeof this.debug === "function") {
this.debug("Opening Web Socket...");
}
- klass = WebSocketStompMock || WebSocket;
+ klass = Stomp.WebSocketClass || WebSocket;
this.ws = new klass(this.url);
this.ws.binaryType = "arraybuffer";
this.ws.onmessage = function(evt) {
@@ -260,7 +258,7 @@ Copyright (C) 2012 FuseSource, Inc. -- http://fusesource.com
window.Stomp = Stomp;
} else {
exports.Stomp = Stomp;
- WebSocketStompMock = require('./test/server.mock.js').StompServerMock;
+ Stomp.WebSocketClass = require('./test/server.mock.js').StompServerMock;
}
}).call(this);
View
4 src/stomp.coffee
@@ -76,7 +76,7 @@ class Client
connect: (login_, passcode_, connectCallback, errorCallback) ->
@debug?("Opening Web Socket...")
- klass = WebSocketStompMock or WebSocket
+ klass = Stomp.WebSocketClass || WebSocket
@ws = new klass(@url)
@ws.binaryType = "arraybuffer"
@ws.onmessage = (evt) =>
@@ -156,4 +156,4 @@ if window?
window.Stomp = Stomp
else
exports.Stomp = Stomp
- WebSocketStompMock = require('./test/server.mock.js').StompServerMock
+ Stomp.WebSocketClass = require('./test/server.mock.js').StompServerMock

0 comments on commit 4751718

Please sign in to comment.
Something went wrong with that request. Please try again.