如何将unityR与unity一起用于客户端服务器通信

时间:2014-10-01 13:04:27

标签: unity3d signalr

任何人都可以告诉我如何在Unity For Client服务器通信中使用signalR。

我的代码出错了。

代码如下:

using UnityEngine;
using System.Collections;
using System;
using System.Threading;
using Microsoft.AspNet.SignalR.Client;

public class SignalR : MonoBehaviour {

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {

    }
}



    public class Client
    {
        private readonly string _platform;
        private readonly HubConnection _connection;
        private readonly IHubProxy _proxy;

        public event EventHandler<EventArgs> OnMessageReceived;

        public Client(string platform)
        {
            _platform = platform;
            _connection = new HubConnection("http://192.168.1.103");
            _proxy = _connection.CreateHubProxy("Chat");
        }

        public void Connect()
        {
             _connection.Start();

            _proxy.On("messageReceived", (string platform, string message) =>
                      {
                if (OnMessageReceived != null)
                    OnMessageReceived(this, string.Format("{0}: {1}", platform, message));
            });

            Send("Connected");
        }

        public void Send(string message)
        {
            return _proxy.Invoke("Send", _platform, message);
        }
    }

这是我的客户端代码。我在我的资产中为signalR添加了ell。

错误详情如下: 内部编译器错误。有关更多信息,请参阅控制台日志。输出是: 未处理的异常:Mono.CSharp.InternalErrorException:Assets / SignalR.cs(30,24):Client.Client(string)---&gt; System.TypeLoadException:无法从程序集“Microsoft.AspNet.SignalR.Client,Version = 2.1.2.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35”加载类型“Microsoft.AspNet.SignalR.Client.Connection”。   at(wrapper managed-to-native)System.MonoType:GetMethodsByName(string,System.Reflection.BindingFlags,bool,System.Type)   在System.MonoType.GetMethods(BindingFlags bindingAttr)[0x00000] in:0

提前致谢!!

0 个答案:

没有答案