Fixes to stream wrapper and bytes wrapper
This commit is contained in:
parent
ac56bd7bdd
commit
dd6f8afc68
@ -353,8 +353,11 @@ trait Files
|
||||
};
|
||||
}
|
||||
$message_media = $this->get_download_info($message_media);
|
||||
if (stream_get_meta_data($stream)['seekable']) {
|
||||
fseek($stream, $offset);
|
||||
try {
|
||||
if (stream_get_meta_data($stream)['seekable']) {
|
||||
fseek($stream, $offset);
|
||||
}
|
||||
} catch (\danog\MadelineProto\Exception $e) {
|
||||
}
|
||||
$downloaded_size = 0;
|
||||
if ($end === -1 && isset($message_media['size'])) {
|
||||
|
@ -30,17 +30,17 @@ class Stream
|
||||
self::$_isRegistered = true;
|
||||
}
|
||||
|
||||
return stream_context_create([self::WRAPPER_NAME => ['handler' => $handler, $stream_id]]);
|
||||
return stream_context_create([self::WRAPPER_NAME => ['handler' => $handler, 'stream_id' => $stream_id]]);
|
||||
}
|
||||
|
||||
public function stream_open($path, $mode, $options, &$opened_path)
|
||||
{
|
||||
$opt = stream_context_get_options($this->context);
|
||||
|
||||
if (!is_array($opt[self::WRAPPER_NAME]) ||
|
||||
!isset($opt[self::WRAPPER_NAME]['handler']) ||
|
||||
!($opt[self::WRAPPER_NAME]['handler'] instanceof Handler) ||
|
||||
!isset($opt[self::WRAPPER_NAME]['stream_id']) ||
|
||||
!is_int($opt[self::WRAPPER_NAME]['stream_id'])) {
|
||||
!isset($opt[self::WRAPPER_NAME]['stream_id'])) {
|
||||
return false;
|
||||
}
|
||||
$this->_handler = $opt[self::WRAPPER_NAME]['handler'];
|
||||
@ -51,7 +51,7 @@ class Stream
|
||||
|
||||
public function stream_write($data)
|
||||
{
|
||||
$this->handler->send_data($this->_stream_id, $data);
|
||||
$this->_handler->send_data($this->_stream_id, $data);
|
||||
}
|
||||
|
||||
public function stream_lock($mode)
|
||||
|
@ -282,6 +282,7 @@ trait TL
|
||||
|
||||
return $concat;
|
||||
case 'bytes':
|
||||
if (is_array($object) && isset($object['_']) && $object['_'] === 'bytes') $object = base64_decode($object['bytes']);
|
||||
if (!is_string($object) && !$object instanceof \danog\MadelineProto\TL\Types\Bytes) {
|
||||
throw new Exception("You didn't provide a valid string");
|
||||
}
|
||||
|
@ -35,6 +35,6 @@ class Bytes extends \Volatile implements \JsonSerializable
|
||||
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return utf8_encode($this->bytes);
|
||||
return ['_' => 'bytes', 'bytes' => base64_encode($this->bytes)];
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ socketMessageResponse request_id:int data:%DataJSON = SocketMessage;
|
||||
socketMessageException request_id:int exception:SocketException = SocketMessage;
|
||||
socketMessageUpdate data:%DataJSON = SocketMessage;
|
||||
socketMessageLog flags:# thread:flags.0?true process:flags.1?true file:string level:int data:%DataJSON = SocketMessage;
|
||||
socketMessageRawData stream_id:int data:bytes = SocketMessage;
|
||||
socketMessageRawData stream_id:string data:bytes = SocketMessage;
|
||||
|
||||
socketException message:string code:int trace:%SocketTLTrace = SocketException;
|
||||
socketRPCErrorException flags:# rpc_message:flags.0?string message:flags.1?string code:int trace:%SocketTLTrace = SocketException;
|
||||
|
Loading…
Reference in New Issue
Block a user