Coder Social home page Coder Social logo

pomelo-unityclient-socket's Introduction

pomelo-unityclient-socket

This is the pomelo dotnet client, support pomelo 0.3 and the new communicate protocol.It is based on native socket. The project is based on some libraries as follows:

Demo

How to use

To use the dotnetClient, just include ./dist/*.dll in your project.

API

Initialize pomelo client

using namespace Pomelo.DotNetClient
string host="127.0.0.1";//(www.xxx.com/127.0.0.1/::1/localhost etc.)
int port=3014;
PomeloClient pclient = new PomeloClient();

//listen on network state changed event
pclient.NetWorkStateChangedEvent += (state) =>
{
    Console.WriteLine(state);
};

pclient.initClient(host, port, () =>
{
    //The user data is the handshake user params
    JsonObject user = new JsonObject();
    pclient.connect(user, data =>
    {
     	//process handshake call back data
    });
});

Use request and response

pclient.request(route, message, (data)=>{
    //process the data
});

Notify server without response

pclient.notify(route, messge);

Add event listener, process broadcast message

pclient.on(route, (data)=>{
    //process the data
});

Disconnect the client.

pclient.disconnect();

protobuf surpported type:uInt32, int32, sInt32, float, double, string.

The dotnet client support dictionary compress and protbuf encode. The use these function, just set the flag at server side. ##License (The MIT License)

Copyright (c) 2012-2013 NetEase, Inc. and other contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

pomelo-unityclient-socket's People

Contributors

demon0925 avatar zk-luke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pomelo-unityclient-socket's Issues

Unity freezing on disconnect

Hi,
I tried this but it always freezing the unity.
void OnApplicationQuit()
{
if (pclient != null)
{
Debug.Log("quit");
pclient.disconnect();
}

}

Unity Web Player

Hi,

You cann't build a Unity3d Web Player Release, the reason for this is the Security Sand Box of the Web Player (see http://docs.unity3d.com/Manual/SecuritySandbox.html).

The following error message appears when you try to build your Unity3d project on the Web Player Platform:
ArgumentException: The Assembly System.Runtime.Serialization is referenced by SimpleJson. But the dll is not allowed to be included or could not be found....
SimpleJson is using Reflections these won't be supported by the Web Player Subset.

At the moment I'm trying to replace the SimpleJson.dll with the SimpleJSON from the Unify Community (http://wiki.unity3d.com/index.php/SimpleJSON). Maybe someone of you could give me some feedback to this decision and/or maybe someone comes up with an other idea.

Best Regards

Flo

bug of HeartBeatService

Hi,

I'm new to client-server sort of things and quite not sure if it's a bug or that's what you intend to do.

For HeartBeatService.cs, the timeout is set to interval*2, but the real timeout happened at interval * 3, coz the timeout is adding up(HeartBeatService.cs line 37~38) below the timeout checking.

Any suggestion? Thanks in advance.

about initClient?

IPAddress[] addresses = Dns.GetHostEntry(host).AddressList;
这句代码经常要执行超3秒

can't parse json array on iOS

We have a handler return json data like this:

{
serverList: [{'a':'some ip'}, {'b': 'an other ip'}]
}

It works fine on Android and HTML, but on iOS will get error and can't get correct data, anybody resolved this problem? or any idea?

Please help, we have work so long on a pomelo game project.

求添加collaborator

sdk里面还有些bug,已经在我的分支上修复,但是现在这个项目处于没人维护的状态,希望能添加我为collaborator参与维护这个项目。

pomelo unity client not working when using domain name and ssl

Hi everybody,

I have user lib pomelo-unityclient-socket to connect server pomelo. But when using domain name it not working.

string host = "mydomaincom";// Not working with domain name
int port = 80;
pc = new PomeloClient(host, port);
pc.connect(null, (data)=>{
JsonObject msg = new JsonObject();
msg["uid"] = "123456";
pc.request("gate.gateHandler.queryEntry", msg, OnQuery);
});

And i don't know using ssl to connect server.

Can any one tell me how using?

Ipv6 fail connect

Hi,

I try to use this with ipv6 and got fail. How can I solve this issue?
Regards,

connect之后就断开了连接

NetWorkStateChangedEvent监听的连接状态state在刚刚new出来的时候是CONNECT,但是调用了connect()之后就变成DISCONNECT了

这个没有人维护了吗?请问怎么重连的。

这个登录后,关闭网络,检测到断开,打开网络,再去new PomeloClient 然后连接服务器 服务器必然出现错误。
[connector-server-1] getSession session is created with session id: 5
[connector-server-1] handleMessage session id: 5, msg: {"id":10001,"type":0,"compressRoute":1,"route":"gate.gateHandler.reqConnect","body":{},"compressGzip":0}

fail to forward message:TypeError: Cannot read property 'forwardMessage' of undefined
无法链接成功

Transporter.cs error

when use protobuf, and handshaked buffer > 1024 , then Transporter error.

file Transporter.cs line 8:
public const int BufferSize = 1024;

cant use Unity APIs in callbacks

I am trying to reimplement chat application.

when I wrote callbacks in client.On and client.request with Unity API. It turned out that those callbacks was called from another thread invoked by async operation.

And all Unity API can only be called from main unity thread.

bug

I am now using flags to indicate callbacks was called. this is obviously a bad idea leading to massy code.

I am wondering if I did something wrong. or there is a better solution?

I am using the latest pomelo-unitylcient-socket and 0.4.1 pomelo server.

bug2

many thanks, 非常感谢

yours sfszh

Long messages causes no response

I ran a few tests using chatofpomelo and the Unity3D demo. Seems like when I am sending more than 1600 characters from the server to unity, unity does not receive anything. Is there a message size limit? or is this a bug? or am i suppose to be using compression? Doesn't seem like a lot of data....

WebGL support?

Any chance of adding WebGL platform support? Thank you.

unity5引入pomelo-dotnetClient.dll后报错

Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in :0
at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in :0
at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in :0
at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in :0
at Mono.CSharp.Driver.LoadReferences () [0x00000] in :0
at Mono.CSharp.Driver.Compile () [0x00000] in :0
at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in :0

是不是编译成dll的.net版本太高了??
使用环境osx10.10.4 unity 5.1.1f1

源代码中握手部分疑惑

internal void start (JsonObject user, Action callback)
{

        this.transporter.start ();
        this.handshake.request (user, callback);
        this.state = ProtocolState.handshaking;
    }

为什么要调用transporter.start,里面方法直接就是接受数据,但是之前没有并没有send数据啊,而数据长度为0还要断开连接,安全搞不懂了。
现在和pomelo握手没有数据返回

about onDisconnect?

旧版本 pomelo-unityclient-socket 有pc.on(PomeloClient.EVENT_DISCONNECT, onDisconnect);的方式获得断线状态。
这个版本如何获得客户端的断线状态呢?另外是否有连接超时时间的设置

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.