package rest_websocket

import (
	"git.ali33.ru/fcg-xvii/go-tools/json"
	"git.ali33.ru/fcg-xvii/rest"
)

type MessageIncoming struct {
	*Message
	socket *WebSocket
}

func (s *MessageIncoming) Type() rest.RequestType {
	return rest.RequestTypeMessage
}

func (s *MessageIncoming) Answer(data json.Map, files map[string]rest.IReadCloserLen) rest.IResponse {
	return &Answer{
		Message: &Message{
			id:    s.id,
			mType: rest.RequestTypeAnswer,
			data:  data,
			files: files,
		},
		socket: s.socket,
	}
}

func (s *MessageIncoming) AnswerError(code int, err rest.IErrorArgs) rest.IResponse {
	return &Answer{
		Message: &Message{
			id:    s.id,
			mType: rest.RequestTypeAnswer,
		},
		err:    err,
		socket: s.socket,
	}
}
