本文整理汇总了C#中IWebSocketConnection类的典型用法代码示例。如果您正苦于以下问题:C# IWebSocketConnection类的具体用法?C# IWebSocketConnection怎么用?C# IWebSocketConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IWebSocketConnection类属于命名空间,在下文中一共展示了IWebSocketConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Client
/// <summary>
/// A fleck client, which provides high-level methods to send data to the client (socket).
/// </summary>
/// <param name="socket">Client socket connection</param>
public Client(IWebSocketConnection socket)
{
State = ClientState.Unknown;
Id = null;
Name = null;
_socket = socket;
}
开发者ID:AlternateIf,项目名称:huddle-engine,代码行数:11,代码来源:Client.cs
示例2: Player
public Player(IWebSocketConnection socket, IPrincipal principal)
{
Principal = principal;
_socket = socket;
_socket.OnMessage = message => MessageRecieved(this, message);
_socket.OnClose += LeaveGame;
}
开发者ID:djcsdy,项目名称:ZenMu,代码行数:7,代码来源:Player.cs
示例3: AddDevice
protected static bool _useSecure = false; //
#endregion Fields
#region Methods
//Add a new device to the list of currently connected devices
private static Device AddDevice(IWebSocketConnection conn, Request requestObject)
{
//Create the device
Device device = new Device()
{
AccountName = requestObject.AccountName,
ConnectionGuid = conn.ConnectionInfo.Id,
FriendlyName = requestObject.FriendlyName,
Id = Guid.Empty,
IP = conn.ConnectionInfo.ClientIpAddress,
Mode = requestObject.CurrentOperationMode
};
//Use the assigned id if the client is supplying one
if (requestObject.DeviceGuid != null)
device.Id = new Guid(requestObject.DeviceGuid); //We have a GUID so update to use that for this connection
//Work out the if we still need a device id and if we do then make one up.
if (device.Id == Guid.Empty) //If the device does not have a guid then request a new one
{
Guid generatedGuid = Guid.NewGuid();
device.Id = generatedGuid;
}//if
//Now actually add the Id to the list
_connectedDevices.TryAdd(device.Id.ToString(), device);
//If we wish to send notifications of on / offline devices then send them now
if (_deviceNotifications)
NotifyDevices(true,device);
//Return the device for use in reading
return device;
}
开发者ID:rockpool,项目名称:LAB_IPTV,代码行数:41,代码来源:program.cs
示例4: handleGame
private void handleGame(IWebSocketConnection socket, String message)
{
Room newRoom = JsonConvert.DeserializeObject<Room>(message);
Room room = Main.ludo.Rooms[newRoom.RoomID];
room.RoomAction = newRoom.RoomAction;
if (room.Game.MoveCount == 0)
{
room.Game.Fields = ludoLogicHandler.initGame(room);
Console.WriteLine(" Init Map: " + room.Game.Fields[0, 0]);
}
if (room.RoomAction.Equals("rollTheDice"))
{
room.Game.DiceValue = rollTheDice();
room.RoomAction = "diceRolled";
Console.WriteLine("Rolled Value: " + room.Game.DiceValue);
room = getUsersTurnID(room);
}
Console.WriteLine("It's " + Main.ludo.Users[room.Game.UsersTurnID].UserName + "'s turn!");
room.Game.MoveCount += 1;
Main.ludo.Rooms[room.RoomID].Game = room.Game;
Console.WriteLine("Field: 0 0" + room.Game.Fields[0, 0]);
Console.WriteLine("Field: 9 0" + room.Game.Fields[9, 0]);
syncGame();
//sendGame(room);
}
开发者ID:Cir0X,项目名称:ludo,代码行数:31,代码来源:GameHandler.cs
示例5: Connection
public void Connection(IWebSocketConnection con, String name)
{
if (isNew) isNew = false;
connections.Add(con, name);
sendToAllNames();
}
开发者ID:rantingmong,项目名称:GameForest,代码行数:7,代码来源:GFXChatLobby.cs
示例6: sendOnlineUsers
private void sendOnlineUsers(IWebSocketConnection socket)
{
foreach (var s in onlineUserSocketList.ToList())
{
s.Send(JsonConvert.SerializeObject(Main.ludo));
}
}
开发者ID:Cir0X,项目名称:ludo,代码行数:7,代码来源:OnlineUserHandler.cs
示例7: ConfigureIntegrationTestConnectionAndGetId
protected int ConfigureIntegrationTestConnectionAndGetId(IWebSocketConnection connection)
{
var id = Interlocked.Increment(ref _idSeed);
connection.OnOpen = () =>
{
AddConnection(id, connection);
Send(id, $"Open: {id}");
};
connection.OnClose = () =>
{
Send(id, $"Close: {id}");
RemoveConnection(id);
};
connection.OnError = ex =>
{
Send(-1, $"Error: {id} - {ex.ToString()}");
};
connection.OnMessage = m =>
{
Send(id, $"User {id}: {m}");
};
return id;
}
开发者ID:tdupont750,项目名称:Owin.WebSocket,代码行数:25,代码来源:FleckTestsBase.cs
示例8: handleRooms
private void handleRooms(IWebSocketConnection socket, String message)
{
Room room = JsonConvert.DeserializeObject<Room>(message);
Console.WriteLine("JSON: " + message);
if (room.RoomAction.Equals("createRoom"))
{
Console.WriteLine("Room " + room.RoomName + " created");
createRoom(room);
}
if (room.RoomAction.Equals("joinRoom"))
{
joinRoom(room);
}
if (room.RoomAction.Equals("leaveRoom"))
{
leaveRoom(room);
}
if (room.RoomAction.Equals("setReady"))
{
setReady(room);
}
if (room.RoomAction.Equals("setStart"))
{
setStart(room);
}
}
开发者ID:Cir0X,项目名称:ludo,代码行数:30,代码来源:RoomHandler.cs
示例9: ServerConfig
public void ServerConfig(IWebSocketConnection socket)
{
socket.OnOpen = () => OnOpen(socket);
socket.OnClose = () => OnClose(socket);
socket.OnMessage = message => OnMessage(socket, message);
socket.OnBinary = bytes => OnBinary(socket, bytes);
}
开发者ID:kesalin,项目名称:CSharpSnippet,代码行数:7,代码来源:WebSocketServer.cs
示例10: NewServiceMap
public WebSocketService NewServiceMap(WebSocketServiceManager _manager, IWebSocketConnection socket)
{
WebSocketService service = null;
switch (_manager.managerName)
{
case "/" + TargetDeiveName.GPS:
service = new GPSService(_manager, socket);
break;
case "/" + TargetDeiveName.UHF:
service = new UHFService(_manager, socket);
break;
case "/" + TargetDeiveName.绿灯:
service = new GreenLightService(_manager, socket);
break;
case "/" + TargetDeiveName.红灯:
service = new RedLightService(_manager, socket);
break;
case "/" + TargetDeiveName.黄灯:
service = new YellowLightService(_manager, socket);
break;
case "/" + TargetDeiveName.电风扇:
service = new FanService(_manager, socket);
break;
case "/" + TargetDeiveName.电机:
service = new EngineService(_manager, socket);
break;
}
return service;
}
开发者ID:ssor,项目名称:iotlab-native,代码行数:29,代码来源:ServiceHost.cs
示例11: Execute
public override ChatCommand Execute(IWebSocketConnection socket)
{
ChatServer.Instance.ClientConnected(this.ClientName, socket);
ChatCommandConnected res = new ChatCommandConnected();
return res;
}
开发者ID:oricalvo,项目名称:course-advfed-sap-2015-07,代码行数:7,代码来源:Connect.cs
示例12: NewServiceMap
public WebSocketService NewServiceMap(WebSocketServiceManager _manager, IWebSocketConnection socket)
{
WebSocketService service = null;
switch (_manager.managerName)
{
case "/gps":
service = new GPSService(_manager, socket);
//service.
break;
case "/uhf":
service = new UHFService(_manager, socket);
break;
case "/green_light":
service = new GreenLightService(_manager, socket);
break;
case "/red_light":
service = new RedLightService(_manager, socket);
break;
case "/yellow_light":
service = new YellowLightService(_manager, socket);
break;
case "/fan":
service = new FanService(_manager, socket);
break;
case "/engine":
service = new EngineService(_manager, socket);
break;
}
return service;
}
开发者ID:ssor,项目名称:iotlab-native,代码行数:30,代码来源:ServiceHost.cs
示例13: closeConnection
public void closeConnection(IWebSocketConnection socket)
{
foreach (var s in allSockets)
{
if (s == socket)
s.Close();
}
}
开发者ID:liuwei0925,项目名称:myPrj,代码行数:8,代码来源:Server.cs
示例14: OnOpen
public void OnOpen(IWebSocketConnection socket)
{
Logger.Instance().InfoWithFormat(" >> client {0} - {1} connected.", socket.ConnectionInfo.ClientIpAddress, socket.ConnectionInfo.Id);
lock (_lockObj)
{
_clientSocketList.Add(socket);
}
}
开发者ID:kesalin,项目名称:CSharpSnippet,代码行数:8,代码来源:WebSocketServer.cs
示例15: FanService
public FanService(WebSocketServiceManager _manager, IWebSocketConnection socket)
{
services.register_service("fan", this);
this.ID = socket.ConnectionInfo.Id.ToString();
this._manager = _manager;
this._websocket = socket;
this._context = socket.ConnectionInfo;
}
开发者ID:ssor,项目名称:iotlab-native,代码行数:8,代码来源:Fan.cs
示例16: sendMessage
public void sendMessage(IWebSocketConnection sock, string msg)
{
foreach (var s in allSockets)
{
if (s == sock)
s.Send(msg);
}
}
开发者ID:liuwei0925,项目名称:myPrj,代码行数:8,代码来源:Server.cs
示例17: sendTo
public void sendTo(IWebSocketConnection socket) {
Dem2Hub.sendItTo(this, socket);
if (operation == 'u' || operation == 'c')
{
var subs = new Subscription() { onEntityId = entity.Id }; //we presume, that the entity will be displayed at the client, so we subscribe him
subs.subscribe(socket);
}
}
开发者ID:capaj,项目名称:Democracy-2.0,代码行数:8,代码来源:entityOperation.cs
示例18: Close
private static void Close(IWebSocketConnection socket)
{
allSockets.Remove(socket);
clientWindows.Remove(socket.ConnectionInfo.Id);
clientDynamicWindows.Remove(socket.ConnectionInfo.Id);
Console.WriteLine("> Socket to " + socket.ConnectionInfo.ClientIpAddress + " closed");
}
开发者ID:developerdizzle,项目名称:SockPuppet,代码行数:8,代码来源:Program.cs
示例19: Remove
public void Remove(IWebSocketConnection con)
{
if (findIfInList(con))
{
connections.Remove(con);
sendToAllNames();
}
}
开发者ID:rantingmong,项目名称:GameForest,代码行数:8,代码来源:GFXChatLobby.cs
示例20: ClientConnected
public void ClientConnected(string name, IWebSocketConnection socket)
{
this.clients.Add(new ChatClient(name, socket));
SendAll(new ChatCommandClientConnected()
{
ClientName = name
});
}
开发者ID:oricalvo,项目名称:course-fed-by-2015-09,代码行数:9,代码来源:ChatServer.cs
注:本文中的IWebSocketConnection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论