本文整理汇总了C#中WebSocketSharp.MessageEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# MessageEventArgs类的具体用法?C# MessageEventArgs怎么用?C# MessageEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageEventArgs类属于WebSocketSharp命名空间,在下文中一共展示了MessageEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnMessage
protected override void OnMessage(MessageEventArgs e)
{
dynamic request = new JavaScriptSerializer().Deserialize(e.Data, typeof(object));
switch ((string)request.action)
{
case "start":
json = new JavaScriptSerializer().Serialize(true);
Telemetry.Game.StartRecording();
break;
case "stop":
Telemetry.Game.StopRecording();
json = new JavaScriptSerializer().Serialize(true);
break;
case "analyse":
Telemetry.Game.AnalyseRecordingForTracks();
// json = new JavaScriptSerializer().Serialize(GameState.TrackAnalysis);
break;
case "loadanalysedtrack":
Track track = Telemetry.Game.BuildTrackData(request.name, request.lap);
json = new JavaScriptSerializer().Serialize(track);
break;
}
Send(json);
}
示例2: client_OnMessage
public static void client_OnMessage(object sender, MessageEventArgs e)
{
string msg = e.Data;
Debug.WriteLine(string.Format("wsGPS OnMessage => {0}", msg));
//�����������Ҫ��ԭʼ����Ӧ�ñ�������֮����Ч��������ͻ���
services.get_service(registe_name).Send(msg);
}
示例3: OnMessage
protected override void OnMessage(MessageEventArgs e)
{
var msg = QueryString.Contains("name")
? String.Format("'{0}' returns to {1}", e.Data, QueryString["name"])
: e.Data;
Send(msg);
}
示例4: Client_Message
private void Client_Message(MessageEventArgs e)
{
if (InvokeRequired)
{
Invoke((MethodInvoker)delegate {
Client_Message(e);
});
return;
}
outputText.AppendText(string.Format("Message Received on {0}:{1}",
DateTime.Now, Environment.NewLine));
if (e.IsBinary)
{
outputText.Append(e.RawData, e.RawData.Length);
}
else
{
outputText.AppendText(e.Data);
}
outputText.AppendText(Environment.NewLine);
outputText.AppendText(Environment.NewLine);
}
示例5: OnMessage
protected override void OnMessage(MessageEventArgs e)
{
if (e == null)
{
throw new ArgumentNullException(nameof(e));
}
log.Info("Received message: \"" + e.Data + "\" of type \"" + e.Type.ToString() + "\"");
if (string.IsNullOrEmpty(e.Data))
return;
using (var session = Bootstrapper.CreateSession())
using (var transaction = session.BeginTransaction())
{
bool commitTransaction = HandleMessage(session, e.Data, (string message) =>
{
log.Info("Sending message: " + message);
Send(message);
});
if (commitTransaction)
transaction.Commit();
else
transaction.Rollback();
}
}
示例6: OnMessage
protected override void OnMessage(MessageEventArgs e)
{
dynamic json = JsonConvert.DeserializeObject<dynamic>(e.Data);
int type;
try
{
type = Convert.ToInt16(json.type);
}
catch
{
return;
}
switch (type)
{
case 0:
ProcessLogin(JsonConvert.DeserializeObject<LoginRequest>(e.Data));
break;
case 1:
ProcessCommand(JsonConvert.DeserializeObject<CommandRequest>(e.Data));
break;
case 4:
GetBans(JsonConvert.DeserializeObject<BanListRequest>(e.Data));
break;
case 5:
GetBEClients(JsonConvert.DeserializeObject<ClientListRequest>(e.Data));
break;
}
}
示例7: OnMessage
protected override void OnMessage(MessageEventArgs e)
{
try
{
switch (e.Type)
{
case Opcode.TEXT:
{
JArray dcode = JArray.Parse(e.Data);
ClientOpcode opcode = (ClientOpcode)int.Parse(dcode[0].ToString());
LogConsole.Show(LogType.DEBUG, "opcode: {0}", opcode);
Program.PacketsManager.ProcessBytes(_session, ref dcode);
break;
}
default:
{
break;
}
}
}
catch (Exception Ex)
{
LogConsole.Show(LogType.ERROR, "{0}", Ex.ToString());
}
}
示例8: OnMessage
protected override void OnMessage(MessageEventArgs e)
{
WSGroupServices.GetLogger().Info("Message received");
try
{
var message = spp.Parse(e.Data);
if (message is Pull)
{
PullHandler();
}
else if (message is Push)
{
PushHandler((Push)message);
}
else if (message is Register)
{
RegisterHandler((Register)message);
}
else { WSGroupServices.GetLogger().Error("Unhandled message type"); }
}
catch (ServerProtocolParsingError)
{
WSGroupServices.GetLogger().Error("Message parsing error:\n" + e.Data.Substring(0, 200));
}
}
示例9: OnRecievedMessage
private void OnRecievedMessage(object sender, MessageEventArgs message)
{
var result = BuildResult.Parse(message.Data);
var msg = result.ToMessage();
if (result.IsFailure)
{
ShowBalloon(ToolTipIcon.Info, msg);
PlaySound(result);
return;
}
if (Settings.Default.ShowErrorOnly)
{
return;
}
if (result.IsSuccess)
{
ShowBalloon(ToolTipIcon.Info, msg);
PlaySound(result);
}
else if (result.IsUnstable)
{
ShowBalloon(ToolTipIcon.Warning, msg);
PlaySound(result);
}
else if (result.IsAborted)
{
ShowBalloon(ToolTipIcon.Info, msg);
PlaySound(result);
}
}
示例10: OnMessage
protected override void OnMessage(MessageEventArgs e)
{
string msg = string.Empty;
string logMsg = string.Empty;
// grab first part of request
// everything before the first _ denotes what method should be called... maybe not very clean...
List<string> parameters = e.Data.Split('_').ToList();
string requestType = parameters[0];
// we've already gotten the requestType, now remove it, so we don't have to work around it
parameters.RemoveAt(0);
switch (requestType)
{
case "getMatchHistory":
Console.WriteLine("Received match history request for: " + parameters[0]);
msg = GetMatchHistory(parameters[0]);
logMsg = "Sent match history response.";
break;
default:
Console.WriteLine("An unknown request was made.");
break;
}
Send(msg);
Console.WriteLine(logMsg);
}
示例11: OnMessage
protected override void OnMessage(MessageEventArgs e) {
string[] sa;
if(e.Type==Opcode.Text && !string.IsNullOrEmpty(e.Data) && (sa=e.Data.Split('\t'))!=null && sa.Length>0) {
if(_verbose.value) {
X13.Log.Debug("ws.msg({0})", string.Join(", ", sa));
}
if(sa[0]=="C" && sa.Length==3) { // Connect, username, password
if((sa[1]!="local" || _ses.ip.IsLocal()) && MQTT.MqBroker.CheckAuth(sa[1], sa[2])) {
_ses.userName=sa[1];
Send("C\ttrue");
if(_verbose.value) {
X13.Log.Info("{0} logon as {1} success", _ses.owner.name, _ses.ToString());
}
} else {
Send("C\tfalse");
if(_verbose.value) {
X13.Log.Warning("{0}@{2} logon as {1} failed", _ses.owner.name, sa[1], _ses.owner.value);
}
Sessions.CloseSession(base.ID);
}
} else if(!_disAnonym.value || (_ses!=null && !string.IsNullOrEmpty(_ses.userName))) {
if(sa[0]=="P" && sa.Length==3) {
HttpWsPl.ProcessPublish(sa[1], sa[2], _ses);
} else if(sa[0]=="S" && sa.Length==2) {
_subscriptions.Add(Topic.root.Subscribe(sa[1], SubChanged));
}
}
}
}
示例12: OnMessage
protected override void OnMessage(MessageEventArgs e)
{
log.Info("Received message: " + e.Data);
if (string.IsNullOrEmpty(e.Data))
return;
var msg = JsonConvert.DeserializeObject<Message>(e.Data);
if (msg == null || string.IsNullOrEmpty(msg.Path) || _servicesDict[msg.Path] == null)
return;
var session = Bootstrapper.CreateSession();
using (var transaction = session.BeginTransaction()) {
bool commitTransaction = true;
_servicesDict[msg.Path].HandleMessage(session, e.Data, (string message) => {
log.Info("Sending message: " + message);
Send(message);
}, ref commitTransaction);
if (commitTransaction)
transaction.Commit();
else
transaction.Rollback();
}
}
示例13: OnMessage
private void OnMessage(object sender, MessageEventArgs e)
{
IService service = e.CallerContext as IService;
service.ServiceManager.Get<ISemanticProcessor>().ProcessInstance<SocketMembrane, ClientSocketMessage>(msg =>
{
msg.Text = e.Data;
});
}
示例14: OnMessageAdv
private void OnMessageAdv(object sender, MessageEventArgs e)
{
JObject body = JObject.Parse(e.Data);
if (body["msg"] == null)
return;
string msg = body["msg"].ToObject<string>();
DdpMessage?.Invoke(this, new DdpMessage(msg, e.Data));
}
示例15: OnSocketMessage
private void OnSocketMessage(object sender, MessageEventArgs e)
{
dynamic message = JsonConvert.DeserializeObject(e.Data);
if (message.type == "message")
{
Log.Write("Recieved message: " + e.Data);
_rtmIncomingMessages.OnMessage(message);
}
}