EventBus icon indicating copy to clipboard operation
EventBus copied to clipboard

Basic Server Client Example not Working.

Open VishalMCF opened this issue 8 months ago • 0 comments

Server main.go

`package main

import ( evbus "github.com/asaskevich/EventBus" )

func main() { server := evbus.NewServer(":8090", "/server_bus", evbus.New()) server.Start() // ... server.EventBus().Publish("main:calculator", 4, 6) }`

Client main.go

` package main

import ( "fmt" evbus "github.com/asaskevich/EventBus" )

func calculator(a int, b int) { fmt.Printf("%d\n", a+b) }

func main() { client := evbus.NewClient(":8089", "/_server_bus", evbus.New()) client.Start() client.Subscribe("main:calculator", calculator, ":8090", "/server_bus") } ` After running the server code I try to run the client and I get this in the console -> Server not found - runtime error: invalid memory address or nil pointer dereference

Can someone please tell me what I am doing wrong?

VishalMCF avatar Dec 06 '23 13:12 VishalMCF