-
大小: 16.68MB文件類型: .rar金幣: 1下載: 0 次發(fā)布日期: 2023-06-19
- 語(yǔ)言: 其他
- 標(biāo)簽:
資源簡(jiǎn)介
可以直接運(yùn)行。請(qǐng)使用hurento server 6.0
代碼片段和文件信息
package?org.kurento.tutorial.one2manycall;
import?java.io.IOException;
import?java.util.HashMap;
import?java.util.Map;
import?java.util.concurrent.ConcurrentHashMap;
import?java.util.concurrent.CopyOnWriteArraySet;
import?javax.websocket.OnClose;
import?javax.websocket.onerror;
import?javax.websocket.OnMessage;
import?javax.websocket.OnOpen;
import?javax.websocket.Session;
import?javax.websocket.server.ServerEndpoint;
import?org.kurento.client.EventListener;
import?org.kurento.client.IceCandidate;
import?org.kurento.client.IceCandidateFoundEvent;
import?org.kurento.client.KurentoClient;
import?org.kurento.client.MediaPipeline;
import?org.kurento.client.WebRtcEndpoint;
import?org.kurento.jsonrpc.JsonUtils;
import?org.slf4j.Logger;
import?org.slf4j.LoggerFactory;
import?com.google.gson.Gson;
import?com.google.gson.GsonBuilder;
import?com.google.gson.Jsonobject;
@ServerEndpoint(“/call“)
public?class?newWebsocket?{
//?靜態(tài)變量,用來(lái)記錄當(dāng)前在線連接數(shù)。應(yīng)該把它設(shè)計(jì)成線程安全的。
private?static?int?onlineCount?=?0;
//?與某個(gè)客戶端的連接會(huì)話,需要通過(guò)它來(lái)給客戶端發(fā)送數(shù)據(jù)
private?Session?session;
private??KurentoClient?kurento=KurentoClient.create(“ws://192.168.1.138:8888/kurento“);
// static?{
//
// if(kurento==null){
// kurento=KurentoClient.create(“ws://192.168.1.138:8888/kurento“);
// }
//
// }
?private?static?final?Logger?log?=?LoggerFactory.getLogger(newWebsocket.class);
??private?static?final?Gson?gson?=?new?GsonBuilder().create();
//??private?final?ConcurrentHashMap?viewers?=?new?ConcurrentHashMap<>();
private?static?MediaPipeline?pipeline;
private?static??UserSession?presenterUserSession;
private?final?static?ConcurrentHashMap?viewers?=?new?ConcurrentHashMap<>();
/**
?*?連接建立成功調(diào)用的方法
?*?
?*?@param?session
?*????????????可選的參數(shù)。session為與某個(gè)客戶端的連接會(huì)話,需要通過(guò)它來(lái)給客戶端發(fā)送數(shù)據(jù)
?*/
@OnOpen
public?void?onOpen(Session?session)?{
this.session?=?session;
addOnlineCount();?//?在線數(shù)加1
System.out.println(“有新連接加入!當(dāng)前在線人數(shù)為“?+?getOnlineCount());
}
/**
?*?連接關(guān)閉調(diào)用的方法
?*/
@OnClose
public?void?onClose()?{
subOnlineCount();?//?在線數(shù)減1
System.out.println(“有一連接關(guān)閉!當(dāng)前在線人數(shù)為“?+?getOnlineCount());
}
/**
?*?收到客戶端消息后調(diào)用的方法
?*?
?*?@param?message
?*????????????客戶端發(fā)送過(guò)來(lái)的消息
?*?@param?session
?*????????????可選的參數(shù)
?*?@throws?IOException
?*/
@OnMessage
public?void?onMessage(String?message?Session?session)?throws?IOException?{
?Jsonobject?jsonMessage?=?gson.fromJson(message?Jsonobject.class);
????log.debug(“Incoming?message?from?session?‘{}‘:?{}“?session.getId()?jsonMessage);
????switch?(jsonMessage.get(“id“).getAsString())?{
??????case?“presenter“:
????????try?{
??????????presenter(session?jsonMessage);
????????}?catch?(Throwable?t)?{
??????????handleErrorResponse(t?session?“presenterResponse“);
????????}
????????break;
??????case?“viewer“:
????????try?{
??????????viewer(session?jsonMessage);
???
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????1639??2016-07-05?11:13??websocket\.classpath
?????文件???????1334??2016-06-01?11:47??websocket\.project
?????文件????????522??2016-06-01?11:44??websocket\.settings\.jsdtscope
?????文件????????598??2016-06-02?10:40??websocket\.settings\org.eclipse.jdt.core.prefs
?????文件????????486??2016-06-01?11:44??websocket\.settings\org.eclipse.wst.common.component
?????文件????????396??2016-06-01?11:44??websocket\.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件?????????49??2016-06-01?11:44??websocket\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件??????????6??2016-06-01?11:44??websocket\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????文件???????2207??2016-06-01?11:46??websocket\src\websocket\EchoServlet.java
?????文件???????2805??2016-07-05?11:16??websocket\src\websocket\Websocket.java
?????文件????????834??2016-06-01?11:44??websocket\WebRoot\index.jsp
?????文件?????????39??2016-06-01?11:44??websocket\WebRoot\me
?????文件???????2111??2016-07-05?11:14??websocket\WebRoot\WEB-INF\classes\websocket\EchoServlet$WebSocketMessageInbound.class
?????文件???????1260??2016-07-05?11:14??websocket\WebRoot\WEB-INF\classes\websocket\EchoServlet.class
?????文件???????3309??2016-07-05?11:18??websocket\WebRoot\WEB-INF\classes\websocket\Websocket.class
?????文件?????188671??2016-07-05?11:12??websocket\WebRoot\WEB-INF\lib\commons-beanutils-1.7.0.jar
?????文件?????575389??2016-07-05?11:12??websocket\WebRoot\WEB-INF\lib\commons-collections-3.2.1.jar
?????文件?????305001??2016-07-05?11:12??websocket\WebRoot\WEB-INF\lib\commons-httpclient-3.1.jar
?????文件?????245274??2016-07-05?11:12??websocket\WebRoot\WEB-INF\lib\commons-lang-2.3.jar
?????文件??????60841??2016-07-05?11:12??websocket\WebRoot\WEB-INF\lib\commons-logging-1.1.1.jar
?????文件??????77826??2016-07-05?11:12??websocket\WebRoot\WEB-INF\lib\ezmorph-1.0.3.jar
?????文件?????148490??2016-07-05?11:12??websocket\WebRoot\WEB-INF\lib\json-lib-2.2.3-jdk15.jar
?????文件????????969??2016-06-01?11:47??websocket\WebRoot\WEB-INF\web.xm
?????文件???????2152??2016-06-02?10:46??websocket\WebRoot\websocket.jsp
?????文件???????4443??2016-07-05?17:45??websocket\WebRoot\wtcnoffer.jsp
?????文件???????4378??2016-07-05?17:45??websocket\WebRoot\wtcoffer.jsp
?????目錄??????????0??2016-07-05?11:14??websocket\WebRoot\WEB-INF\classes\websocket
?????目錄??????????0??2016-07-05?11:14??websocket\WebRoot\WEB-INF\classes
?????目錄??????????0??2016-07-05?11:12??websocket\WebRoot\WEB-INF\lib
?????目錄??????????0??2016-06-02?10:39??websocket\src\websocket
............此處省略428個(gè)文件信息
評(píng)論
共有 條評(píng)論