-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
41 lines (30 loc) · 805 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"fmt"
"log"
"net"
"google.golang.org/grpc"
proto "github.com/atharv-bhadange/grpc-chat/gen"
"github.com/atharv-bhadange/grpc-chat/handler"
)
func main() {
// Create a new gRPC server
grpcServer := grpc.NewServer()
// Create a new connection pool
var conn []*handler.Connection
pool := &handler.Pool{
Connection: conn,
}
// Register the pool with the gRPC server
proto.RegisterBroadcastServer(grpcServer, pool)
// Create a TCP listener at port 8080
listener, err := net.Listen("tcp", ":8080")
if err != nil {
log.Fatalf("Error creating the server %v", err)
}
fmt.Println("Server started at port :8080")
// Start serving requests at port 8080
if err := grpcServer.Serve(listener); err != nil {
log.Fatalf("Error creating the server %v", err)
}
}