コード例 #1
0
ファイル: voicetarget.go プロジェクト: tarantoj/gumble
func (vt *VoiceTarget) writeMessage(client *Client) error {
	packet := MumbleProto.VoiceTarget{
		Id:      &vt.ID,
		Targets: make([]*MumbleProto.VoiceTarget_Target, 0, len(vt.users)+len(vt.channels)),
	}
	for _, user := range vt.users {
		packet.Targets = append(packet.Targets, &MumbleProto.VoiceTarget_Target{
			Session: []uint32{user.Session},
		})
	}
	for _, vtChannel := range vt.channels {
		target := &MumbleProto.VoiceTarget_Target{
			ChannelId: &vtChannel.channel.ID,
			Links:     &vtChannel.links,
			Children:  &vtChannel.recursive,
		}
		if vtChannel.group != "" {
			target.Group = &vtChannel.group
		}
		packet.Targets = append(packet.Targets, target)
	}

	proto := protoMessage{&packet}
	return proto.writeMessage(client)
}
コード例 #2
0
func (vt *VoiceTarget) writeTo(client *Client, w io.Writer) (int64, error) {
	packet := MumbleProto.VoiceTarget{
		Id:      proto.Uint32(uint32(vt.id)),
		Targets: make([]*MumbleProto.VoiceTarget_Target, 0, len(vt.users)+len(vt.channels)),
	}
	for _, user := range vt.users {
		packet.Targets = append(packet.Targets, &MumbleProto.VoiceTarget_Target{
			Session: []uint32{user.session},
		})
	}
	for _, vtChannel := range vt.channels {
		packet.Targets = append(packet.Targets, &MumbleProto.VoiceTarget_Target{
			ChannelId: &vtChannel.channel.id,
			Links:     &vtChannel.links,
			Children:  &vtChannel.recursive,
		})
	}

	proto := protoMessage{&packet}
	return proto.writeTo(client, w)
}