GithubHelp home page GithubHelp logo

Comments (5)

perling1 avatar perling1 commented on July 1, 2024

To give more insight, the callback onlogout works as described. It doesnt throw a nil pointer panic.

func main() {
	settings := gopher.ServerSettings{
		ServerName:     "myserv01",
		MaxConnections: 6,

		HostName:  "localhost",
		HostAlias: "localhost",
		IP:        "localhost",
		Port:      8080,

		TLS:         false,
		CertFile:    "",
		PrivKeyFile: "",

		OriginOnly: false,

		MultiConnect:   false,
		KickDupOnLogin: false,

		UserRoomControl:   true,
		RoomDeleteOnLeave: true,

		EnableSqlFeatures: false,
		SqlIP:             "localhost",
		SqlPort:           3306,
		SqlProtocol:       "tcp",
		SqlUser:           "user",
		SqlPassword:       "password",
		SqlDatabase:       "database",
		EncryptionCost:    4,
		CustomLoginColumn: "",
		RememberMe:        false,
		EnableRecovery:   false,
		RecoveryLocation: "C:/",
		AdminLogin:       "admin",
		AdminPassword:    "1234",
	}
	setErrs := gopher.SetLogoutCallback(clientLoggedOut)
	if setErrs != nil {
		fmt.Println(setErrs)
	}
	gopher.Start(&settings)
}

func clientLoggedOut(userName string, databaseID int) {
	fmt.Println("Entered")
}

The nil pointer comes from line125 in callbacks.go
its the only line of code that tries to access the setting by *

if (*settings).EnableSqlFeatures {

from gophergameserver.

hewiefreeman avatar hewiefreeman commented on July 1, 2024

Oh, this is an interesting problem. Thanks for bringing it to my attention! It seems there was an oversight on the flow of starting the server. For now, you could make a method UpdateSettings(s *ServerSettings) in server.go that replaces the // Set server settings potion of the Start() function (just cut-paste into the new function). Then you can update the settings before calling SetLogoutCallback() or anything else that needs it before starting. I just don't have the time to get around to this for a day or so.

from gophergameserver.

perling1 avatar perling1 commented on July 1, 2024

Another problem is golang cant include pullrequests from github modules.
I have modified the server.go, but i cant get it loaded in my project as its not a "master" oder "stable" version.

from gophergameserver.

hewiefreeman avatar hewiefreeman commented on July 1, 2024

This project hasn't been set up with go modules. At least not yet. I've been able to use GGS along with other Go APIs without modules. Are you sure your project is in the right gopath to prevent it from using modules?

from gophergameserver.

perling1 avatar perling1 commented on July 1, 2024

I was maybe to unspecific. I use a go.mod file with my own fork

go.mod
require (
	github.com/perling1/GopherGameServer v0.0.0-20220214170824-f4a7d5e6619a // indirect
)

In the main testserver.go file:

import (
...	
gopher "github.com/perling1/GopherGameServer"
	"github.com/perling1/GopherGameServer/actions"
	"github.com/perling1/GopherGameServer/core"
)
..
       gopher.UpdateServerSettings(&settings)
	setErrs = gopher.SetLoginCallback(clientLoggedIn)

Because if i import your GGS github.com/hewiefreeman/GopherGameServer/
my pullrequest wasnt imported , so the func "gopher.UpdateServerSettings(&settings) " didnt exist.

Its a big hassle to import "github libs" that change. you have to use terminal commands to reset caches
go mod -clean
go mod tidy
go get github.com/perling1/GopherGameServer@master

Thats an annoying act while using "go and mod". Its not due to your project.

from gophergameserver.

Related Issues (4)

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.