Code Monkey home page Code Monkey logo

nano's People

Contributors

adoontheway avatar bbdshow avatar beatless avatar brcoding avatar carmark avatar chalvern avatar clearcodecn avatar colin1989 avatar cute-angelia avatar dvrkps avatar gsw945 avatar lacorey avatar lewgun avatar lonng avatar maciekmm avatar nicholaschan1025 avatar supermario1990 avatar zlonglin 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  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

nano's Issues

rpc没有返回

rpc的实现相当于notify

func (a *agent) RPC(route string, v interface{}) error {
if a.status() == statusClosed {
return ErrBrokenPipe
}
data, err := message.Serialize(v)
if err != nil {
return err
}
msg := &message.Message{
Type: message.Notify,
Route: route,
Data: data,
}
a.rpcHandler(a.session, msg, true)
return nil
}

希望返回interface, err := a.rpcHandler(a.session, msg, true), 这个interface可以转成需要的类型,不知道大家怎么处理的??

What is the cluster restart sequence after a code change?

Question

What is the cluster restart sequence after a code change?
Does it support independent restart?
The problem currently encountered is that the session is not synchronized after restarting a service alone.

✅Searched existing Stack Overflow questions.
✅Googled your question.
✅Searched open and closed GitHub issues

多Gate sessionId 无法保证全局唯一

Question

当需要水平扩展 Gate时,无法保证 session id 全局唯一。
当前实现方式是依据 session id 标记 session 资源。
当出现 CloseSession 的时候,如果不同的用户出现相同的 sessionId, 是否会导致 close 误伤?
经测试 相同的sessionId 确实存在。
当初要采用 session id, 而不是采用 uid 方式关联,是基于什么思考?
有其他方式可以绕开这一问题吗?

Server间如何不透过session进行rpc?

目前看范例上的rpc只能透过session进行rpc行為,
请问nano有办法让server间可以直接rpc,
实现像pomelo的remote rpc机制吗?谢谢。

Go Client Example?

Hi

I'm just wondering if there is a Go client example (not HTML+JS) anywhere?

Thanks

Ken

golang client

Hi,
thanks for great framework.
Can you give me a golang client example.
thank you.

Someone who understands go and English PLEASE FIX DOCUMENTATION

The English in the documentation is very not good. As a beginner to golang and nano, I'm having a lot of trouble understanding it.

Eg;
While handling a message, the handler will receive two arguments, session corresponding a client and a message is the payload of this request that unmarshals by nano automatically.

While handling a message, the handler will receive two arguments, a session id corresponding to a client and a content indicating the payload of the request....

Okay? I had to read through it several times to understand that far.

However, you lost me at unmarshals.

If anyone knows both English and go and nano and can go through the docs it would be a great help...

In Get Started

In Get Started the following methods are undefined: OnSessionClosed, Register, SetSerializer, EnableDebug.

undefined: nano.OnSessionClosed
undefined: nano.Register
undefined: nano.SetSerializer
undefined: nano.EnableDebug

Then the example uses methods from both chat and cluster packages without import them.

Chat example is not working because of nano.ListenWS( ) is not defined

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. What did you do? If possible, provide a recipe for reproducing the error.

I Tried to run the chat example, using go run main.go but it wasn't possible because of the nano.ListenWS is no longer available.

2. What did you expect to see?

Chat example running

3. What did you see instead?

./main.go:153:2: undefined: nano.ListenWS

4. Versions of the nano

I cloned the repository at 2019-08029, not sure the version.

cluster模式,s.RPC通讯不能获取到另一个服务的错误

Question

示例网关节点服务A:
err := s.RPC("TopicService.NewUser", request)
fmt.Println(err,"-------------------err")
if err != nil {
return errors.Trace(err)
}

Master节点服务B:
func (ts *TopicService) NewUser(s *session.Session, msg *protocol.NewUserRequest) error {
fmt.Println("---------------NewUser err")
return errors.Trace(errors.New("------------------123 err return"))

问题:服务B不管是关闭进程还是正常返回错误,服务A的s.RPC调用后err永远是nil

more examples

Hi.
I wish there were more complicated examples and full working ones. like a simple game with simple authentication gateway.
it's a little confusing for me.
how to have authentication gate?

nano should add uid in gRPC request

Since nano did not implement SESSION-UID binding broadcast like pomelo, I think that nano should add uid with SessionID in gRPC request so that user could maintain unique sid-uid binding at frontend named "connector"

close of closed channel when `Close` session in concurrent context

package main

import (
	"errors"
	"fmt"
	"sync/atomic"
	"time"
)

type test struct {
	status int32
	chDie  chan struct{}
}

func (t *test) Close() error {
	if atomic.LoadInt32(&t.status) > 0 {
		return errors.New("closed test")
	}

	// wait another gorontine enter block
	time.Sleep(time.Second)

	atomic.StoreInt32(&t.status, 1)

	close(t.chDie)
	return nil
}

func main() {
	fmt.Println("Hello, 世界")
	t := &test{chDie: make(chan struct{})}

	go t.Close()
	go t.Close()

	time.Sleep(3 * time.Second)
}

Session.Close will occur the same problem show in above.

如何让comment在指定的goroutine中运行?

1.我想让不同的comment在不同的goroutine中运行,但是
只看到了handler中的localProcess的注释和schd的定义,
但是没有example,希望可以写个eample演示一下.万分感谢

2.看了下关于分布式的实现,很想知道为什么不用成熟的etcd,consul方案,需要自己实现一下注册中心呢?

服务多开怎么处理group

Question

type RoomService struct {
	component.Base
	group *nano.Group
}

func newRoomService() *RoomService {
	return &RoomService{
		group: nano.NewGroup("all-users"),
	}
}

比如这个服务多开几个,客户端连接分散这些服务,无法统一收到消息,这个怎么处理呢?

Detect rpc call success

Hi,

if err := s.RPC("TopicService.NewUser", request); err != nil {
		return errors.Trace(err)
	}

above code is in cluster example.
How can i check TopicService.NewUser is success or error.
Currenty error is traced only when the TopicService down

thank you.

use of internal package not allowed

这个是啥问题,go run main.go
../../pkg/mod/github.com/lonnng/[email protected]/agent.go:31:2: use of internal package github.com/lonng/nano/internal/codec not allowed
../../pkg/mod/github.com/lonnng/[email protected]/agent.go:32:2: use of internal package github.com/lonng/nano/internal/message not allowed
../../pkg/mod/github.com/lonnng/[email protected]/agent.go:33:2: use of internal package github.com/lonng/nano/internal/packet not allowed

package main

import (
"fmt"
"log"
"net/http"

"github.com/lonnng/nano"
"github.com/lonnng/nano/component"
"github.com/lonnng/nano/serialize/json"
"github.com/lonnng/nano/session"

)

type (
// define component
Room struct {
component.Base
group *nano.Group
}

// protocol messages
UserMessage struct {
	Name    string `json:"name"`
	Content string `json:"content"`
}

NewUser struct {
	Content string `json:"content"`
}

AllMembers struct {
	Members []int64 `json:"members"`
}

JoinResponse struct {
	Code   int    `json:"code"`
	Result string `json:"result"`
}

)

func NewRoom() *Room {
return &Room{
group: nano.NewGroup("room"),
}
}

func (r *Room) AfterInit() {
nano.OnSessionClosed(func(s *session.Session) {
r.group.Leave(s)
})
}

// Join room
func (r *Room) Join(s *session.Session, msg []byte) error {
s.Bind(s.ID()) // binding session uid
s.Push("onMembers", &AllMembers{Members: r.group.Members()})
// notify others
r.group.Broadcast("onNewUser", &NewUser{Content: fmt.Sprintf("New user: %d", s.ID())})
// new user join group
r.group.Add(s) // add session to group
return s.Response(&JoinResponse{Result: "sucess"})
}

// Send message
func (r *Room) Message(s *session.Session, msg *UserMessage) error {
return r.group.Broadcast("onMessage", msg)
}

func main() {
nano.Register(NewRoom())
nano.SetSerializer(json.NewSerializer())
nano.EnableDebug()
log.SetFlags(log.LstdFlags | log.Llongfile)

http.Handle("/web/", http.StripPrefix("/web/", http.FileServer(http.Dir("web"))))

nano.SetCheckOriginFunc(func(_ *http.Request) bool { return true })
nano.Listen(":3250", nano.WithIsWebsocket(true))

}

route compression

Hey,
I did a lot of benchmarks between nano and pomelo

nano wins every time.
seems golang is a much better choice for server side then javascript(who knew ;-) )

so I'm looking to move my server side project to nano
if I'll find any bugs I will report them or try to contribute fixes.

though I have a question when route compression will be implemented,
as it's pretty important and I only saw test code for it

the tadpole demo run problem

**/github.com/lonnng/nano/app.go:120: Upgrade failure, URI=/favicon.ico, Error=websocket: the client is not using the websocket protocol: 'upgrade' token not found in 'Connection' header

how to solve the problem

Handshake Package 中如何自定义握手数据验证

Handshake Package 中如何自定义握手数据验证

client demo和文档中有出现
{ "sys": { "version": "1.1.1", "type": "js-websocket" }, "user": { // Any customized request data } }
的描述
code - 握手响应的状态码。目前的取值:200代表成功,500为处理用户自定义握手流程时失败,501为客户端版 本号不符合要求。
sys.heartbeat - 可选,心跳时间间隔,单位为秒,没指定表示不需要心跳。
dict - 可选,route字段压缩的映射表,没指定表示没有字典压缩。
protos - 可选,protobuf压缩的数据定义,没有表示没有protobuf压缩。
user - 可选,用户自定义的握手数据,没有表示没有用户自定义的握手数据。

服务端关于user的数据如何验证?

Kick数据包类型并没有实现封装调用入口吗

Question @lonng

// Kick represents a kick off packet
Kick = 0x05 // disconnect message from server

请问这个数据包类型并没有实现吗?
源码没有一个地方调用过该类型。应该需要额外加一个类似s.Response接口来处理Kick类型的数据包吧。

客户端虽然有这个数据包类型的定义接收,但是服务端没有实现这个数据包类型的封装?
handlers[Package.TYPE_KICK] = onKick;

Cannot send messages larger than 2048 bytes

Bug Report

Cannot send messages larger than 2048 bytes.
Sending a message greater than 2048 results in an error, It's pretty certain。

buf := make([]byte, 2048) Unable to read the full message causing an error
This code needs to be modified to read all the message contents at once.

lastAt of agent has data racing

The lastAt of agent is simultaneous reading and writing in two goroutines ( respectively in nano's reading and writing goroutines ), which means data race.

Feature Request: Demo with Unity

Hello There!

In the online Gaming Industry, Unity has a strong hold for frontend.
Do you think having Unity Demo under example will attract more contributors in community and gain attention on people in the industry?!

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.