tinymsg/msg

为 tiny 实时消息服务器提供的客户端

0.1.0 2016-03-20 23:11 UTC

This package is not auto-updated.

Last update: 2024-09-26 00:10:02 UTC


README

为 tiny 实时消息服务器提供的客户端,请参阅https://github.com/iamso/tinymsg

安装

使用 Composer

运行以下命令

composer require tinymsg/msg

或将包添加到您的 composer.json

{
  "require": {
    "tinymsg/msg": "*"
  }
}

### 不使用 Composer

只需下载并放置在某个位置即可 :)

用法

包含

// With Composer
require 'vendor/autoload.php';

// Without Composer
require 'path/to/tinymsg/msg.php';

创建实例

// Importing the namespace
use tinymsg\Msg;

// Server without SSL
$msg = new Msg('channel-name', 'tinymsg.domain.tld');

// Server with SSL
$msg = new Msg('channel-name', 'tinymsg.domain.tld', true);

// Localhost with special port
$msg = new Msg('channel-name', 'localhost:7777', false, 7777);

// Using the fully qualified namespace name
$msg = new tinymsg/Msg(...);

发送消息

// Send a message
$msg->send('string');
$msg->send(array(1,2,3,4));
$msg->send(array('key' => 'value'));

打开/关闭套接字

在创建 Msg 实例时,构造函数会打开套接字连接。如果需要,您可以关闭并重新打开连接。

// Close the socket connection
$msg->close();

// (Re-) Open the socket connection
$msg->open();

许可协议

版权所有 (c) 2016 Steve Ottoz

特此授予任何获得此软件及其相关文档副本(以下简称“软件”)的个人免费使用权,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本的权利,并允许提供软件的个人为此目的进行操作,但须遵守以下条件

上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。

本软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、特定用途的适用性和非侵权性。在任何情况下,作者或版权持有人均不对任何索赔、损害或其他责任承担责任,无论这些责任是基于合同、侵权或其他原因,无论这些责任是否源于、源于或与软件或软件的使用或其他操作有关。