notes
parent
ec67b3169d
commit
9824fecaa2
|
@ -106,6 +106,26 @@ func (s *gameWorldServer) HandleCmd(verb, rest string, sender *db.Object) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
what's the flow for when i'm at a computer and type /say hi ?
|
||||||
|
|
||||||
|
- server gets "SAY hi" from vilmibm
|
||||||
|
- server gets all objects in earshot (including vilmibm's avatar)
|
||||||
|
- for each object:
|
||||||
|
- call whatever handler it has for "hears"
|
||||||
|
|
||||||
|
and then that's it, right? over in witch land:
|
||||||
|
|
||||||
|
- hears handler for an avatar has:
|
||||||
|
|
||||||
|
tellMe(sender.get("name") + " says " + msg)
|
||||||
|
|
||||||
|
- tellMe somehow calls a method on the gameWorldServer that can look up a
|
||||||
|
session ID and thus use the msgRouter to send a message. I'm going to sleep
|
||||||
|
on this so I can think about the right way to structure those dependencies.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
func (s *gameWorldServer) Commands(stream proto.GameWorld_CommandsServer) error {
|
func (s *gameWorldServer) Commands(stream proto.GameWorld_CommandsServer) error {
|
||||||
var sid string
|
var sid string
|
||||||
for {
|
for {
|
||||||
|
@ -138,6 +158,12 @@ func (s *gameWorldServer) Commands(stream proto.GameWorld_CommandsServer) error
|
||||||
}
|
}
|
||||||
log.Printf("found avatar %#v", avatar)
|
log.Printf("found avatar %#v", avatar)
|
||||||
|
|
||||||
|
affected, err := s.db.Earshot(*avatar)
|
||||||
|
|
||||||
|
for _, o := range affected {
|
||||||
|
err = s.Gateway.VerbHandler(cmd.Verb, cmd.Rest, *avatar, o)
|
||||||
|
}
|
||||||
|
|
||||||
s.HandleCmd(cmd.Verb, cmd.Rest, avatar)
|
s.HandleCmd(cmd.Verb, cmd.Rest, avatar)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -37,6 +37,10 @@ has({
|
||||||
hears(".*eat.*", function(msg)
|
hears(".*eat.*", function(msg)
|
||||||
does("quivers nervously")
|
does("quivers nervously")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
hears(".*", function(msg)
|
||||||
|
tellMe(sender().name + " says " + msg)
|
||||||
|
end)
|
||||||
`
|
`
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -94,14 +98,14 @@ func NewGateway(cb func(string, string, *db.Object)) *Gateway {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Gateway) VerbHandler(verb, rest string, sender, target *db.Object) error {
|
func (g *Gateway) VerbHandler(verb, rest string, sender, target db.Object) error {
|
||||||
var sc *scriptContext
|
var sc *scriptContext
|
||||||
g.mu.RLock()
|
g.mu.RLock()
|
||||||
sc, ok := g.m[target.ID]
|
sc, ok := g.m[target.ID]
|
||||||
g.mu.RUnlock()
|
g.mu.RUnlock()
|
||||||
|
|
||||||
if !ok || sc.NeedsRefresh(*target) {
|
if !ok || sc.NeedsRefresh(target) {
|
||||||
sc, err := newScriptContext(*target)
|
sc, err := newScriptContext(target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -111,7 +115,7 @@ func (g *Gateway) VerbHandler(verb, rest string, sender, target *db.Object) erro
|
||||||
g.mu.Unlock()
|
g.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
sc.Handle(verb, rest, sender, target)
|
sc.Handle(verb, rest, &sender, &target)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue