Skip to content

Commit

Permalink
Add a new pitaya client with protocol buffers support. (#75)
Browse files Browse the repository at this point in the history
* Add a new pitaya protocol buffers client.

* Change channel pointer to a simple channel in ClienteInterface.

* Improve the documentation and solve some issues.

* Improve functions comments.

* Fix a typo and change the IncomingMsgChan buffer size.
  • Loading branch information
capella authored and andrehp committed Dec 17, 2018
1 parent 118993b commit 4c4013d
Show file tree
Hide file tree
Showing 19 changed files with 1,131 additions and 199 deletions.
30 changes: 16 additions & 14 deletions benchmark/testdata/test.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions client/client.go
Expand Up @@ -90,6 +90,16 @@ type Client struct {
messageEncoder message.Encoder
}

// MsgChannel return the incoming message channel
func (c *Client) MsgChannel() chan *message.Message {
return c.IncomingMsgChan
}

// ConnectedStatus return the connection status
func (c *Client) ConnectedStatus() bool {
return c.Connected
}

// New returns a new client
func New(logLevel logrus.Level, requestTimeout ...time.Duration) *Client {
l := logrus.New()
Expand Down
35 changes: 35 additions & 0 deletions client/pitayaclient.go
@@ -0,0 +1,35 @@
// Copyright (c) TFG Co. All Rights Reserved.
//
// 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.

package client

import (
"github.com/topfreegames/pitaya/conn/message"
)

type PitayaClient interface {
ConnectTo(addr string) error
ConnectToTLS(addr string, skipVerify bool) error
Disconnect()
SendNotify(route string, data []byte) error
SendRequest(route string, data []byte) (uint, error)
ConnectedStatus() bool
MsgChannel() chan *message.Message
}

0 comments on commit 4c4013d

Please sign in to comment.