mirror of
https://github.com/vacp2p/dasy.git
synced 2026-01-08 22:37:59 -05:00
added message, basic send func
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"github.com/golang/protobuf/proto"
|
||||
mvds "github.com/status-im/mvds/node"
|
||||
"github.com/status-im/mvds/protobuf"
|
||||
"github.com/status-im/mvds/state"
|
||||
)
|
||||
|
||||
@@ -43,3 +45,17 @@ func (c *Client) Ack(chat Chat, messageID []byte) {
|
||||
func (c *Client) Post(chat Chat, body []byte) {
|
||||
|
||||
}
|
||||
|
||||
func (c *Client) send(chat Chat, message *protobuf.Message) error {
|
||||
buf, err := proto.Marshal(message)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = c.node.AppendMessage(state.GroupID(chat), buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
155
protobuf/message.pb.go
Normal file
155
protobuf/message.pb.go
Normal file
@@ -0,0 +1,155 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: protobuf/message.proto
|
||||
|
||||
package message
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type Message_MessageType int32
|
||||
|
||||
const (
|
||||
Message_INVITE Message_MessageType = 0
|
||||
Message_JOIN Message_MessageType = 1
|
||||
Message_LEAVE Message_MessageType = 2
|
||||
Message_KICK Message_MessageType = 3
|
||||
Message_ACK Message_MessageType = 4
|
||||
Message_POST Message_MessageType = 5
|
||||
)
|
||||
|
||||
var Message_MessageType_name = map[int32]string{
|
||||
0: "INVITE",
|
||||
1: "JOIN",
|
||||
2: "LEAVE",
|
||||
3: "KICK",
|
||||
4: "ACK",
|
||||
5: "POST",
|
||||
}
|
||||
|
||||
var Message_MessageType_value = map[string]int32{
|
||||
"INVITE": 0,
|
||||
"JOIN": 1,
|
||||
"LEAVE": 2,
|
||||
"KICK": 3,
|
||||
"ACK": 4,
|
||||
"POST": 5,
|
||||
}
|
||||
|
||||
func (x Message_MessageType) String() string {
|
||||
return proto.EnumName(Message_MessageType_name, int32(x))
|
||||
}
|
||||
|
||||
func (Message_MessageType) EnumDescriptor() ([]byte, []int) {
|
||||
return fileDescriptor_8368f5d77b0b9b7b, []int{0, 0}
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
Clock uint64 `protobuf:"varint,1,opt,name=clock,proto3" json:"clock,omitempty"`
|
||||
Timestamp uint64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
|
||||
MessageType Message_MessageType `protobuf:"varint,3,opt,name=message_type,json=messageType,proto3,enum=Message_MessageType" json:"message_type,omitempty"`
|
||||
Body [][]byte `protobuf:"bytes,4,rep,name=body,proto3" json:"body,omitempty"`
|
||||
Signature [][]byte `protobuf:"bytes,5,rep,name=signature,proto3" json:"signature,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Message) Reset() { *m = Message{} }
|
||||
func (m *Message) String() string { return proto.CompactTextString(m) }
|
||||
func (*Message) ProtoMessage() {}
|
||||
func (*Message) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_8368f5d77b0b9b7b, []int{0}
|
||||
}
|
||||
|
||||
func (m *Message) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Message.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Message.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Message) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Message.Merge(m, src)
|
||||
}
|
||||
func (m *Message) XXX_Size() int {
|
||||
return xxx_messageInfo_Message.Size(m)
|
||||
}
|
||||
func (m *Message) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Message.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Message proto.InternalMessageInfo
|
||||
|
||||
func (m *Message) GetClock() uint64 {
|
||||
if m != nil {
|
||||
return m.Clock
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Message) GetTimestamp() uint64 {
|
||||
if m != nil {
|
||||
return m.Timestamp
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Message) GetMessageType() Message_MessageType {
|
||||
if m != nil {
|
||||
return m.MessageType
|
||||
}
|
||||
return Message_INVITE
|
||||
}
|
||||
|
||||
func (m *Message) GetBody() [][]byte {
|
||||
if m != nil {
|
||||
return m.Body
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Message) GetSignature() [][]byte {
|
||||
if m != nil {
|
||||
return m.Signature
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("Message_MessageType", Message_MessageType_name, Message_MessageType_value)
|
||||
proto.RegisterType((*Message)(nil), "Message")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("protobuf/message.proto", fileDescriptor_8368f5d77b0b9b7b) }
|
||||
|
||||
var fileDescriptor_8368f5d77b0b9b7b = []byte{
|
||||
// 225 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2b, 0x28, 0xca, 0x2f,
|
||||
0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0xcf, 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, 0x4f, 0xd5, 0x03, 0x0b, 0x28,
|
||||
0x7d, 0x65, 0xe4, 0x62, 0xf7, 0x85, 0x88, 0x08, 0x89, 0x70, 0xb1, 0x26, 0xe7, 0xe4, 0x27, 0x67,
|
||||
0x4b, 0x30, 0x2a, 0x30, 0x6a, 0xb0, 0x04, 0x41, 0x38, 0x42, 0x32, 0x5c, 0x9c, 0x25, 0x99, 0xb9,
|
||||
0xa9, 0xc5, 0x25, 0x89, 0xb9, 0x05, 0x12, 0x4c, 0x60, 0x19, 0x84, 0x80, 0x90, 0x39, 0x17, 0x0f,
|
||||
0xd4, 0xc0, 0xf8, 0x92, 0xca, 0x82, 0x54, 0x09, 0x66, 0x05, 0x46, 0x0d, 0x3e, 0x23, 0x11, 0x3d,
|
||||
0xa8, 0x99, 0x30, 0x3a, 0xa4, 0xb2, 0x20, 0x35, 0x88, 0x3b, 0x17, 0xc1, 0x11, 0x12, 0xe2, 0x62,
|
||||
0x49, 0xca, 0x4f, 0xa9, 0x94, 0x60, 0x51, 0x60, 0xd6, 0xe0, 0x09, 0x02, 0xb3, 0x41, 0x56, 0x15,
|
||||
0x67, 0xa6, 0xe7, 0x25, 0x96, 0x94, 0x16, 0xa5, 0x4a, 0xb0, 0x82, 0x25, 0x10, 0x02, 0x4a, 0xde,
|
||||
0x5c, 0xdc, 0x48, 0xa6, 0x09, 0x71, 0x71, 0xb1, 0x79, 0xfa, 0x85, 0x79, 0x86, 0xb8, 0x0a, 0x30,
|
||||
0x08, 0x71, 0x70, 0xb1, 0x78, 0xf9, 0x7b, 0xfa, 0x09, 0x30, 0x0a, 0x71, 0x72, 0xb1, 0xfa, 0xb8,
|
||||
0x3a, 0x86, 0xb9, 0x0a, 0x30, 0x81, 0x04, 0xbd, 0x3d, 0x9d, 0xbd, 0x05, 0x98, 0x85, 0xd8, 0xb9,
|
||||
0x98, 0x1d, 0x9d, 0xbd, 0x05, 0x58, 0x40, 0x42, 0x01, 0xfe, 0xc1, 0x21, 0x02, 0xac, 0x49, 0x6c,
|
||||
0x60, 0xef, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x3c, 0x96, 0xc5, 0x8a, 0x18, 0x01, 0x00,
|
||||
0x00,
|
||||
}
|
||||
19
protobuf/message.proto
Normal file
19
protobuf/message.proto
Normal file
@@ -0,0 +1,19 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message Message {
|
||||
|
||||
enum MessageType {
|
||||
INVITE = 0;
|
||||
JOIN = 1;
|
||||
LEAVE = 2;
|
||||
KICK = 3;
|
||||
ACK = 4;
|
||||
POST = 5;
|
||||
}
|
||||
|
||||
uint64 clock = 1;
|
||||
uint64 timestamp = 2;
|
||||
MessageType message_type = 3;
|
||||
repeated bytes body = 4;
|
||||
repeated bytes signature = 5;
|
||||
}
|
||||
Reference in New Issue
Block a user