github.com/hahmadia/mattermost-server@v5.11.1+incompatible/model/websocket_request.go (about)

     1  // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package model
     5  
     6  import (
     7  	"encoding/json"
     8  	"io"
     9  
    10  	goi18n "github.com/nicksnyder/go-i18n/i18n"
    11  )
    12  
    13  type WebSocketRequest struct {
    14  	// Client-provided fields
    15  	Seq    int64                  `json:"seq"`
    16  	Action string                 `json:"action"`
    17  	Data   map[string]interface{} `json:"data"`
    18  
    19  	// Server-provided fields
    20  	Session Session              `json:"-"`
    21  	T       goi18n.TranslateFunc `json:"-"`
    22  	Locale  string               `json:"-"`
    23  }
    24  
    25  func (o *WebSocketRequest) ToJson() string {
    26  	b, _ := json.Marshal(o)
    27  	return string(b)
    28  }
    29  
    30  func WebSocketRequestFromJson(data io.Reader) *WebSocketRequest {
    31  	var o *WebSocketRequest
    32  	json.NewDecoder(data).Decode(&o)
    33  	return o
    34  }