var client = new JsonRpcClient("ws://localhost:8080/phone/ws/websocket",
		onRequest);

var localPeerConnection;

function onRequest(transaction, message) {
	
	if (message.method === "incommingCall") {
		onIncommingCall(transaction, message);
	} else if (message.method === "startCommunication") {
		onStartCommunication(transaction, message);
	} else {
		console.error("Unrecognized request: " + JSON.stringify(message));
	}
}

function onIncommingCall(transaction, request) {

	prepareSendPlayer(function(peerConnection, offer) {

		localPeerConnection = peerConnection;

		transaction.sendResponse({
			callResponse : "Accept",
			sdpOffer : offer.sdp
		});
	});
}

function onStartCommunication(transaction, request) {
	prepareReceivePlayer(localPeerConnection, request.params.sdpAnswer);
	
	transaction.sendResponse({});
}

function register() {

	var name = document.getElementById("name").value;

	client.sendRequest("register", {
		name : name
	}, function() {
		console.log("registered");
	});
}

function call() {

	var peer = document.getElementById("peer").value;

	prepareSendPlayer(function(peerConnection, offer) {

		localPeerConnection = peerConnection;
		
		client.sendRequest("call", {
			callTo : peer,
			sdpOffer : offer.sdp
		}, function(error, result) {
			prepareReceivePlayer(localPeerConnection, result.sdpAnswer);			
		});	
	});
}
@@ -85,34 +85,8 @@
 );%0A%0A
-var localPeerConnection;%0A%0A
 func
@@ -1102,51 +1102,8 @@
  %7B%0A%0A
-%09%09localPeerConnection = peerConnection;%0A%09%09%0A
 %09%09cl
@@ -1218,38 +1218,33 @@
 reReceivePlayer(
-localP
+p
 eerConnection, r
@@ -1260,19 +1260,16 @@
 Answer);
-%09%09%09
 %0A%09%09%7D);%09%0A
@@ -1270,12 +1270,13 @@
 %09%7D);%09%0A%09%7D);%0A%7D
+%0A

Remove useless localPeerConnection variable