Loading CHANGELOG.md +2 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ All notable changes to this project are documented below. The format is based on [keep a changelog](http://keepachangelog.com/) and this project uses [semantic versioning](http://semver.org/). ## [Unreleased] ### Added - RUDP transport option for client connections. ### [1.1.0] - 2017-10-17 ### Added Loading Gopkg.lock +10 −4 Original line number Diff line number Diff line Loading @@ -77,8 +77,8 @@ [[projects]] name = "github.com/gorilla/websocket" packages = ["."] revision = "1f512fc3f05332ba7117626cdfb4e07474e58e60" version = "v1.0.0" revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b" version = "v1.2.0" [[projects]] name = "github.com/lib/pq" Loading Loading @@ -106,6 +106,12 @@ revision = "69483b4bd14f5845b5a1e55bca19e954e827f1d0" version = "v1.1.4" [[projects]] branch = "master" name = "github.com/wirepair/netcode" packages = ["."] revision = "14d712a4beed1986c5739f12cc0ab307fe0c8771" [[projects]] name = "github.com/yuin/gopher-lua" packages = [".","ast","parse","pm"] Loading @@ -125,7 +131,7 @@ [[projects]] name = "golang.org/x/crypto" packages = ["bcrypt","blowfish"] packages = ["bcrypt","blowfish","chacha20poly1305","chacha20poly1305/internal/chacha20","poly1305"] revision = "f6b343c37ca80bfa8ea539da67a0b621f84fab1d" [[projects]] Loading @@ -152,6 +158,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 inputs-digest = "9bb457dbd056b3d2d11c7230286f5f8e0e5320e125201c02663c6c2f11d5b23e" inputs-digest = "35278ed3991c30453da43a354426a228439d974e91cb9dd5f6992f71681f7306" solver-name = "gps-cdcl" solver-version = 1 Gopkg.toml +4 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ [[constraint]] name = "github.com/gorilla/websocket" version = "~1.0.0" version = "~1.2.0" [[constraint]] name = "github.com/lib/pq" Loading Loading @@ -65,3 +65,6 @@ [[constraint]] name = "golang.org/x/net" [[constraint]] name = "github.com/wirepair/netcode" main.go +2 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import ( _ "github.com/lib/pq" "github.com/satori/go.uuid" "go.uber.org/zap" "runtime" ) const ( Loading Loading @@ -74,7 +75,7 @@ func main() { // Print startup information multiLogger.Info("Nakama starting") multiLogger.Info("Node", zap.String("name", config.GetName()), zap.String("version", semver)) multiLogger.Info("Node", zap.String("name", config.GetName()), zap.String("version", semver), zap.String("runtime", runtime.Version())) multiLogger.Info("Data directory", zap.String("path", config.GetDataDir())) multiLogger.Info("Database connections", zap.Strings("dsns", config.GetDatabase().Addresses)) Loading pkg/multicode/byte_array_rw.go 0 → 100644 +100 −0 Original line number Diff line number Diff line // Copyright 2017 The Nakama Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package multicode import "io" type ByteArrayReaderWriter struct { data []byte readPosition int writePosition int } // TODO Cache and reuse? func NewByteArrayReaderWriter(data []byte) *ByteArrayReaderWriter { return &ByteArrayReaderWriter{ data: data, readPosition: 0, writePosition: 0, } } // Reset the read position in the stream to the given offset relative to the beginning of the stream. func (s *ByteArrayReaderWriter) SeekRead(offset int) int { s.readPosition = offset return s.readPosition } // Reset the read position in the stream to the given offset relative to the beginning of the stream. func (s *ByteArrayReaderWriter) SeekWrite(offset int) int { s.writePosition = offset return s.writePosition } func (s *ByteArrayReaderWriter) ReadByte() (byte, error) { buf := make([]byte, 1) if s.read(buf, 0, 1) != 1 { return 0, io.EOF } return buf[0], nil } func (s *ByteArrayReaderWriter) ReadUint16() (uint16, error) { buf := make([]byte, 2) if s.read(buf, 0, 2) != 2 { return 0, io.EOF } return uint16(uint32(buf[0]) | uint32(buf[1]<<8)), nil } func (s *ByteArrayReaderWriter) ReadBuffer(buf []byte, length int) error { if s.read(buf, 0, length) != length { return io.EOF } return nil } func (s *ByteArrayReaderWriter) WriteByte(b byte) { s.write([]byte{b}, 0, 1) } func (s *ByteArrayReaderWriter) WriteUint16(u uint16) { s.write([]byte{byte(u), byte(uint32(u) >> 8)}, 0, 2) } func (s *ByteArrayReaderWriter) WriteBuffer(buf []byte, length int) { s.write(buf, 0, length) //for i := 0; i < length; i++ { // s.WriteByte(buf[i]) //} } func (s *ByteArrayReaderWriter) read(buffer []byte, offset, count int) int { readBytes := 0 length := len(s.data) for i := 0; i < count && s.readPosition < length; i++ { buffer[i+offset] = s.data[s.readPosition] s.readPosition++ readBytes++ } return readBytes } func (s *ByteArrayReaderWriter) write(buffer []byte, offset, count int) { for i := 0; i < count; i++ { s.data[s.writePosition] = buffer[i+offset] s.writePosition++ } } Loading
CHANGELOG.md +2 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,8 @@ All notable changes to this project are documented below. The format is based on [keep a changelog](http://keepachangelog.com/) and this project uses [semantic versioning](http://semver.org/). ## [Unreleased] ### Added - RUDP transport option for client connections. ### [1.1.0] - 2017-10-17 ### Added Loading
Gopkg.lock +10 −4 Original line number Diff line number Diff line Loading @@ -77,8 +77,8 @@ [[projects]] name = "github.com/gorilla/websocket" packages = ["."] revision = "1f512fc3f05332ba7117626cdfb4e07474e58e60" version = "v1.0.0" revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b" version = "v1.2.0" [[projects]] name = "github.com/lib/pq" Loading Loading @@ -106,6 +106,12 @@ revision = "69483b4bd14f5845b5a1e55bca19e954e827f1d0" version = "v1.1.4" [[projects]] branch = "master" name = "github.com/wirepair/netcode" packages = ["."] revision = "14d712a4beed1986c5739f12cc0ab307fe0c8771" [[projects]] name = "github.com/yuin/gopher-lua" packages = [".","ast","parse","pm"] Loading @@ -125,7 +131,7 @@ [[projects]] name = "golang.org/x/crypto" packages = ["bcrypt","blowfish"] packages = ["bcrypt","blowfish","chacha20poly1305","chacha20poly1305/internal/chacha20","poly1305"] revision = "f6b343c37ca80bfa8ea539da67a0b621f84fab1d" [[projects]] Loading @@ -152,6 +158,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 inputs-digest = "9bb457dbd056b3d2d11c7230286f5f8e0e5320e125201c02663c6c2f11d5b23e" inputs-digest = "35278ed3991c30453da43a354426a228439d974e91cb9dd5f6992f71681f7306" solver-name = "gps-cdcl" solver-version = 1
Gopkg.toml +4 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ [[constraint]] name = "github.com/gorilla/websocket" version = "~1.0.0" version = "~1.2.0" [[constraint]] name = "github.com/lib/pq" Loading Loading @@ -65,3 +65,6 @@ [[constraint]] name = "golang.org/x/net" [[constraint]] name = "github.com/wirepair/netcode"
main.go +2 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import ( _ "github.com/lib/pq" "github.com/satori/go.uuid" "go.uber.org/zap" "runtime" ) const ( Loading Loading @@ -74,7 +75,7 @@ func main() { // Print startup information multiLogger.Info("Nakama starting") multiLogger.Info("Node", zap.String("name", config.GetName()), zap.String("version", semver)) multiLogger.Info("Node", zap.String("name", config.GetName()), zap.String("version", semver), zap.String("runtime", runtime.Version())) multiLogger.Info("Data directory", zap.String("path", config.GetDataDir())) multiLogger.Info("Database connections", zap.Strings("dsns", config.GetDatabase().Addresses)) Loading
pkg/multicode/byte_array_rw.go 0 → 100644 +100 −0 Original line number Diff line number Diff line // Copyright 2017 The Nakama Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package multicode import "io" type ByteArrayReaderWriter struct { data []byte readPosition int writePosition int } // TODO Cache and reuse? func NewByteArrayReaderWriter(data []byte) *ByteArrayReaderWriter { return &ByteArrayReaderWriter{ data: data, readPosition: 0, writePosition: 0, } } // Reset the read position in the stream to the given offset relative to the beginning of the stream. func (s *ByteArrayReaderWriter) SeekRead(offset int) int { s.readPosition = offset return s.readPosition } // Reset the read position in the stream to the given offset relative to the beginning of the stream. func (s *ByteArrayReaderWriter) SeekWrite(offset int) int { s.writePosition = offset return s.writePosition } func (s *ByteArrayReaderWriter) ReadByte() (byte, error) { buf := make([]byte, 1) if s.read(buf, 0, 1) != 1 { return 0, io.EOF } return buf[0], nil } func (s *ByteArrayReaderWriter) ReadUint16() (uint16, error) { buf := make([]byte, 2) if s.read(buf, 0, 2) != 2 { return 0, io.EOF } return uint16(uint32(buf[0]) | uint32(buf[1]<<8)), nil } func (s *ByteArrayReaderWriter) ReadBuffer(buf []byte, length int) error { if s.read(buf, 0, length) != length { return io.EOF } return nil } func (s *ByteArrayReaderWriter) WriteByte(b byte) { s.write([]byte{b}, 0, 1) } func (s *ByteArrayReaderWriter) WriteUint16(u uint16) { s.write([]byte{byte(u), byte(uint32(u) >> 8)}, 0, 2) } func (s *ByteArrayReaderWriter) WriteBuffer(buf []byte, length int) { s.write(buf, 0, length) //for i := 0; i < length; i++ { // s.WriteByte(buf[i]) //} } func (s *ByteArrayReaderWriter) read(buffer []byte, offset, count int) int { readBytes := 0 length := len(s.data) for i := 0; i < count && s.readPosition < length; i++ { buffer[i+offset] = s.data[s.readPosition] s.readPosition++ readBytes++ } return readBytes } func (s *ByteArrayReaderWriter) write(buffer []byte, offset, count int) { for i := 0; i < count; i++ { s.data[s.writePosition] = buffer[i+offset] s.writePosition++ } }