package chat import ( "time" "git.ali33.ru/fcg-xvii/go-tools/json" "git.ali33.ru/fcg-xvii/rest" ) type User struct { ID int64 `rest:"default"` Name string `rest:"default"` Password string `rest:"ignore"` Streams []rest.IStream } func (s *User) SendMessage(sender *User, message string, file rest.IReadCloserLen) { var files map[string]rest.IReadCloserLen if file != nil { files = make(map[string]rest.IReadCloserLen) } req := rest.NewRequestStream( time.Now().Add(time.Second*5), &rest.Request{ Type: rest.RequestTypeEvent, Command: "/users/message", Data: json.Map{ "sender": sender, "message": message, }, Files: files, }, ) for _, stream := range s.Streams { stream.SendMessage(req) } }