本文整理汇总了C#中WebSocketSession.Close方法的典型用法代码示例。如果您正苦于以下问题:C# WebSocketSession.Close方法的具体用法?C# WebSocketSession.Close怎么用?C# WebSocketSession.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebSocketSession
的用法示例。
在下文中一共展示了WebSocketSession.Close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: appServer_SessionClosed
static void appServer_SessionClosed(WebSocketSession session, CloseReason closeRs)
{
session.Close();
Console.WriteLine("客户端" + session.RemoteEndPoint.Port + "断开了连接!");
ClientNum -= 1;
Console.WriteLine("客户端数目" + ClientNum.ToString());
}
示例2: ProcessMessage
void ProcessMessage(WebSocketSession session,string type,string[] args)
{
switch(type){
case "join":
var result=CheckJoinRequset(session,args);
session.Send(CreateMessage(new[]{"joinres",(string)result.IsSucceeded.ToString(),(string)result.Message}));
if(result.IsSucceeded){
if(NewUserAdded!=null){
sessions.Add(args[0],session);
NewUserAdded(session,new UserEventArgs(args[0]));
}
}else session.Close();
break;
case "message":
var name=sessions.FirstOrDefault(pair=>pair.Value==session).Key;
if(name!=""&&args.Length>0&&MessageReceived!=null)
MessageReceived(session,new MessageReceivedEventArgs(name,args[0]));
break;
case "screenshotres":
name=sessions.FirstOrDefault(pair=>pair.Value==session).Key;
if(name!=""&&args.Length>0){
ThreadPool.QueueUserWorkItem((arg)=>{
var data=ConvertData(arg as string);
if(ScreenShotReceived!=null)
ScreenShotReceived(session,new ScreenShotReceivedEventArgs(name,data));
},args[0]);
}
break;
default:
break;
}
}
示例3: socketServer_NewSessionConnected
//--------------------------------------------------------------------------------------------------
//--------------------------------WS --------------------------------------------------
//--------------------------------------------------------------------------------------------------
private static void socketServer_NewSessionConnected(WebSocketSession session)
{
var portName = session.Path.Replace("/", "");
if (portName != null && portName != "")
{
portName = portName.Replace("/", "");
Info("Sock client " + session.SessionID + " connected with path " + portName);
try
{
var cfg = PortOpen(portName, 0);
session.Send(JsonConvert.SerializeObject(cfg));
session.Path = portName;
return;
}
catch (Exception e){
session.Send("{ \"error\": \"" + e.Message + "\"}");
}
}
else
{
Info("Sock client " + session.SessionID + " connected without path ");
session.Send(JsonConvert.SerializeObject(ComPortConfigs));
}
session.Close();
}
示例4: ExecuteCommand
public override void ExecuteCommand(WebSocketSession session, SubRequestInfo requestInfo)
{
session.Close();
}
示例5: socketServer_NewSessionConnected
static void socketServer_NewSessionConnected(WebSocketSession session)
{
String acceptedOrigin = "http://192.168.31.68";
//Console.WriteLine(session.RemoteEndPoint.Address.ToString());
Console.WriteLine(session.Origin);
if (session.Origin.Equals(acceptedOrigin)) {
lock (m_SessionSyncRoot)
m_Sessions.Add (session);
SendToAll ("System: " + session.SessionID + " connected");
} else {
session.Close(CloseReason.SocketError);
}
}