我正在使用 xSockets 在 Windows Phone 8 上创建一个简单的聊天应用程序,但我遇到以下问题,运行时它说“不包含调用方法的定义”,我在某处读到我必须使用 Dispatch,但也没有运气。
我的代码:
private async void Connect()
{
Connection = new XSocketClient(ServerURI, Origin, "chat");
chatController = Connection.Controller("chat");
//Handle incoming event from server: use Invoke to write to console from XSocket's thread
chatController.On<string>("addMessage", message => this.Invoke((Action)(() =>
RichTextBoxConsole.Text =(String.Format("{0}" + Environment.NewLine, message))
)));
try
{
Connection.Open();
comboBoxLocation.SelectedIndex = 0;
await chatController.SetProperty("username", UserName);
}
catch
{
StatusText.Text = "Unable to connect to server: Start server before connecting clients.";
No connection: Don't enable Send button or show chat UI
return;
}
}