service

package
v0.96.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NONE                  byte = 0
	UNKNOWN               byte = 1
	NOT_RECEIVED          byte = 2
	NOT_RECEIVED_SURE     byte = 3
	RECEIVED              byte = 4
	ACKNOWLEDGED          byte = 8
	NEED_NO_ACK           byte = 16
	RPC_PROCESSING        byte = 32
	RESPONSE_GENERATED    byte = 64
	RESPONSE_ACKNOWLEDGED byte = 128
)
	case mtpc_msgs_state_req: {
		if (badTime) {
			DEBUG_LOG(("Message Info: skipping with bad time..."));
			return HandleResult::Ignored;
		}
		MTPMsgsStateReq msg;
		msg.read(from, end);
		auto &ids = msg.c_msgs_state_req().vmsg_ids.v;
		auto idsCount = ids.size();
		DEBUG_LOG(("Message Info: msgs_state_req received, ids: %1").arg(LogIdsVector(ids)));
		if (!idsCount) return HandleResult::Success;

		QByteArray info(idsCount, Qt::Uninitialized);
		{
			QReadLocker lock(sessionData->receivedIdsMutex());
			auto &receivedIds = sessionData->receivedIdsSet();
			auto minRecv = receivedIds.min();
			auto maxRecv = receivedIds.max();

			QReadLocker locker(sessionData->wereAckedMutex());
			const auto &wereAcked = sessionData->wereAckedMap();
			const auto wereAckedEnd = wereAcked.cend();

			for (uint32 i = 0, l = idsCount; i < l; ++i) {
				char state = 0;
				uint64 reqMsgId = ids[i].v;
				if (reqMsgId < minRecv) {
					state |= 0x01;
				} else if (reqMsgId > maxRecv) {
					state |= 0x03;
				} else {
					auto msgIdState = receivedIds.lookup(reqMsgId);
					if (msgIdState == ReceivedMsgIds::State::NotFound) {
						state |= 0x02;
					} else {
						state |= 0x04;
						if (wereAcked.constFind(reqMsgId) != wereAckedEnd) {
							state |= 0x80; // we know, that server knows, that we received request
						}
						if (msgIdState == ReceivedMsgIds::State::NeedsAck) { // need ack, so we sent ack
							state |= 0x08;
						} else {
							state |= 0x10;
						}
					}
				}
				info[i] = state;
			}
		}
		emit sendMsgsStateInfoAsync(msgId, info);
	} return HandleResult::Success;

 1    = nothing is known about the message (msg_id too low, the other party may have forgotten it)
 2    = message not received (msg_id falls within the range of stored identifiers;
	    however, the other party has certainly not received a message like that)
 3    = message not received (msg_id too high; however, the other party has certainly not received it yet)
 4    = message received (note that this response is also at the same time a receipt acknowledgment)
 +8   = message already acknowledged
 +16  = message not requiring acknowledgment
 +32  = RPC query contained in message being processed or processing already complete
 +64  = content-related response to message already generated
 +128 = other party knows for a fact that message is already received

Variables

This section is empty.

Functions

func ParseFromIncomingMessage

func ParseFromIncomingMessage(b []byte) (salt, sessionId int64, msg2 *mtproto.TLMessage2, err error)

func SerializeToBuffer

func SerializeToBuffer(x *mtproto.EncodeBuf, salt, sessionId int64, msg2 *mtproto.TLMessage2, layer int32) error

func SerializeToBuffer2

func SerializeToBuffer2(salt, sessionId int64, msg2 *mtproto.TLMessageRawData) []byte

Types

type Gateway

type Gateway struct {
	// contains filtered or unexported fields
}

Gateway eGateClient is a gateway.

func NewGateway

func NewGateway(c zrpc.RpcClientConf) (*Gateway, error)

NewSession new a comet.

func (*Gateway) Close

func (c *Gateway) Close() (err error)

func (*Gateway) SendDataToGate

func (c *Gateway) SendDataToGate(ctx context.Context, authKeyId, sessionId int64, payload []byte) (b bool, err error)

SendDataToGate egate.sendDataToGateway auth_key_id:long session_id:long payload:bytes = Bool;

type RequestManager

type RequestManager struct {
	// contains filtered or unexported fields
}

func NewRequestManager

func NewRequestManager() *RequestManager

type Service

type Service struct {
	*dao.Dao
	// contains filtered or unexported fields
}

func New

func New(c config.Config) *Service

func (*Service) Close

func (s *Service) Close() error

func (*Service) DeleteByAuthKeyId

func (s *Service) DeleteByAuthKeyId(authKeyId int64)

func (*Service) Ping

func (s *Service) Ping(ctx context.Context) (err error)

Ping ping the resource.

func (*Service) SendDataToGateway

func (s *Service) SendDataToGateway(ctx context.Context, gatewayId string, authKeyId, salt, sessionId int64, msg *mtproto.TLMessageRawData) (bool, error)

func (*Service) SendHttpDataToGateway

func (s *Service) SendHttpDataToGateway(ctx context.Context, ch chan interface{}, authKeyId, salt, sessionId int64, msg *mtproto.TLMessageRawData) (bool, error)

func (*Service) SessionCloseSession

func (s *Service) SessionCloseSession(ctx context.Context, r *sessionpb.TLSessionCloseSession) (*mtproto.Bool, error)

func (*Service) SessionCreateSession

func (s *Service) SessionCreateSession(ctx context.Context, r *sessionpb.TLSessionCreateSession) (*mtproto.Bool, error)

func (*Service) SessionPushRpcResultData

func (s *Service) SessionPushRpcResultData(ctx context.Context, r *sessionpb.TLSessionPushRpcResultData) (*mtproto.Bool, error)

func (*Service) SessionPushSessionUpdatesData

func (s *Service) SessionPushSessionUpdatesData(ctx context.Context, r *sessionpb.TLSessionPushSessionUpdatesData) (*mtproto.Bool, error)

SessionPushSessionUpdatesData RPCPushClient is the client API for RPCPush service.

func (*Service) SessionPushUpdatesData

func (s *Service) SessionPushUpdatesData(ctx context.Context, r *sessionpb.TLSessionPushUpdatesData) (*mtproto.Bool, error)

SessionPushUpdatesData RPCPushClient is the client API for RPCPush service.

func (*Service) SessionQueryAuthKey

func (s *Service) SessionQueryAuthKey(ctx context.Context, r *sessionpb.TLSessionQueryAuthKey) (*mtproto.AuthKeyInfo, error)

func (*Service) SessionSendDataToSession

func (s *Service) SessionSendDataToSession(ctx context.Context, r *sessionpb.TLSessionSendDataToSession) (res *mtproto.Bool, err error)

func (*Service) SessionSendHttpDataToSession

func (s *Service) SessionSendHttpDataToSession(ctx context.Context, r *sessionpb.TLSessionSendHttpDataToSession) (res *sessionpb.HttpSessionData, err error)

func (*Service) SessionSetAuthKey

func (s *Service) SessionSetAuthKey(ctx context.Context, r *sessionpb.TLSessionSetAuthKey) (*mtproto.Bool, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL