-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
38 lines (31 loc) · 1 KB
/
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
package main
import (
"fmt"
"groupschemepoc1/p2pnet"
"groupschemepoc1/pubsub"
"github.com/libp2p/go-libp2p/core/protocol"
)
const topic = "rex/groupscheme/test"
const service = "rex/service/groupschema/test"
const subtopic = "rex/groupscheme/test/sub"
const testProtocol = "/test/0.1"
const GroupJoinRequestProtocol = "/rex/request"
const GroupJoinReplyProtocol = "rex/reply"
var testsucc bool = false
func main() {
ctx, host := p2pnet.EstablishP2P()
host.SetStreamHandler(protocol.ID(GroupJoinRequestProtocol), pubsub.HandleStreamJoinRequest)
host.SetStreamHandler(protocol.ID(GroupJoinReplyProtocol), pubsub.RecieveReply)
kad_dht := p2pnet.HandleDHT(ctx, host)
pubSub := pubsub.SetUpPubSub(ctx, host)
p2phost := p2pnet.NewP2P(ctx, host, kad_dht, pubSub)
grp, err := pubsub.JoinGroup(p2phost, "", topic)
pubsub.CurrentGroupRoom = grp
if err != nil {
fmt.Println("Error while joining the group")
}
go grp.HandleInputFromSDI(ctx, host)
go p2pnet.DiscoverPeers(ctx, host, kad_dht, service)
for {
}
}