Дерево страниц

Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.
Комментарий: Published by Scroll Versions from space TMINT and version 7.0
Sv translation
languageru

Примеры представляют собой исходные коды консольных утилит, которые реализуют загрузку событий в Traffic Monitor, используя Thrift-интерфейс pushAPI SDK.

Первая утилита – pushapi-cpp. Реализована на языке С++. Подготовлена к сборке в операционных системах Windows и Linux. Данная утилита демонстрирует сценарии загрузки всех типов событий, которые уже зарегистрированы в системе Traffic Monitor.

Вторая утилита – pushapi-csharp. Реализована на языке С#. Подготовлена к сборке в операционной системе Windows. Данная утилита демонстрирует сценарии загрузки всех типов событий, которые уже зарегистрированы в системе Traffic Monitor.

Третья утилита – pushapi-demo.py. Реализована на языке Python. Подготовлена к сборке в операционных системах Windows и Linux. Демонстрирует сценарии загрузки всех типов событий, которые уже зарегистрированы в системе Traffic Monitor.

Четвертая утилита – pushapi-util. Реализована на языке С++. Подготовлена к сборке в операционных системах Windows и Linux. Данная утилита имеет развитый интерфейс командной строки, который позволяет загружать произвольные события в систему Traffic Monitor, в том числе те, которые зарегистрированы внешней системой. Вот описание командной строки:

./pusheventpushapi-util
--host <pushapi address > [--port <pushapi port>]
--token <plugin token>
--id <company>

--class <event class>
--service <event service>

--evtattr <attr_name:attr_value,…, attr_name:attr_value>
--sender <contact_type:contact_value,attr_name:attr_value,…,attr_name:attr_value>
--receiver <contact_type:contact_value,attr_name:attr_value,…,attr_name:attr_value>
--data file:<data_falie_name>, attr_name:attr_value,…, attr_name:attr_value
--mes <contact_type:contact_value,"message text"
[–addctx]

Где:

  • <pushapi address > – адрес pushAPI-сервера;
  • <pushapi port> – порт pushAPI-сервера, если не указан, используется значение по умолчанию;
  • <plugin token> – токен авторизации плагина. Берётся из консоли в разделе данного плагина;
  • <company> – идентификатор компании-производителя плагина. Произвольная строка, обязательно совпадающая с той, что использовалась для генерации лицензии для плагина;
  • <event class> – класс передаваемого события;
  • <event service> – сервис передаваемого события. Плагин может зарегистрировать свои перехватываемые сервисы по имени и передавать их;
  • --evtattr – атрибуты передаваемого события. Посмотреть можно в списке команд с примером. Некоторые имена атрибутов имеют фиксированные значения и бизнес-смысл;
  • --sender – отправитель события. Первая пара параметров определяет контакт отправителя. Далее указываются атрибуты отправителя. Существуют три «особых» типа контактов: dev (отправитель/получатель является устройством), res (отправитель/получатель является ресурсом), ws (отправитель/получатель является «Рабочей станцией»). Если не задан ни один отправитель, то будет сгенерировано два отправителя с типом «Персона» и контактом типа «auth»; и с типом «Рабочая станция» и контактом dnshostname. Задан может быть только один отправитель;

    Примечание
    iconfalse
    titleПример:

    Для события с отправителем с аккаунтом Вконтакте и указанием мета-информации:
    --sender "vkontakte:349051292:'{\"display_name\":\"some name\",\"url\":\"some_url\",\"login\":\"some_login\"}'"

  • --receiver – получатель события. Параметры аналогичны отправителю;
  • --data – данные события. Первая пара атрибутов указывает на путь к файлу, где содержится тело события. Остальные параметры описывают атрибуты этих данных. Для некоторых типов событий некоторые атрибуты обязательны;
  • --mes – передача сообщений класса «Беседа». Указывается контакт отправителя сообщения и его содержимое. Сообщений может быть несколько;
  • --addctx – необязательный параметр. Автоматически добавляет к событию двух отправителей с типом «Персона» и контактом типа «auth»; и с типом «Рабочая станция» и контактом типа dnshostname.

Примеры вызова этой утилиты есть в исходных кодах примеров.
Кроме этого в состав примеров SDK входит:

  • файл pluging.json – JSON-схема файла manifest.json, который включается в состав файла регистрации внешнего плагина;
  • файл plugin.zip – пример файла регистрации внешнего плагина.

    Предупреждение
    titleВажно!

    В состав файла входит просроченная лицензия. Для регистрации плагина на основании файла примера нужно будет получать новую лицензию.

Sv translation
languageen

Samples are the source codes of console utilities, which implement loading events into Traffic Monitor using Thrift interface of pushAPI SDK.
The first utility is pushapi-cpp. It is implemented in С++ and prepared for assembly in Windows and Linux operating systems. This utility demonstrates scripts of loading all event types that are already registered with Traffic Monitor. 

The second utility is pushapi-csharp. It is implemented in С# and prepared for assembly in Windows operating system. This utility demonstrates scripts of loading all event types that are already registered with Traffic Monitor.

The third utility is pushapi-demo.py. Is implemented in Python. Is prepared for assembly in Windows and Linux operating systems. This utility demonstrates scripts of loading all event types that are already registered with Traffic Monitor.

The fourth utility is pushapi-util. It is implemented in С++ and prepared for assembly in Windows and Linux operating systems. This utility has an advanced command-line interface which enables uploading any events to Traffic Monitor system, including events registered with an external system. Here is the command line description:

./pushevent-util 
--host <pushapi address > [--port <pushapi port>] 
--token <plugin token> 
--id <company>

--class <event class> 
--service <event service>

--evtattr <attr_name:attr_value,…, attr_name:attr_value>
--sender <contact_type:contact_value,attr_name:attr_value,…,attr_name:attr_value>
--receiver <contact_type:contact_value,attr_name:attr_value,…,attr_name:attr_value>
--data file:<data_falie_name>, attr_name:attr_value,…, attr_name:attr_value
--mes <contact_type:contact_value,"message text"
[–addctx]

Where:

  • <pushapi address > – pushAPI server address;
  • <pushapi port> – pushAPI server port; if the port is not specified, a default value is used;
  • <plugin token> – the plugin authorization token. Is It is retrieved from the console, from the section of the given plugin;
  • <company> – an identifier of the plugin vendor. A string. Must , which must be the same as the string used for generating a license for the plugin;
  • <event class> – the class of the passed event;
  • <event service> – the service of the passed event. The plugin can register intercepted services by their names and pass the names;
  • --evtattr – attributes of the passed event. Can be viewed in the list of commands with a sample. Some attribute names have fixed values and business sense;
  • --sender – the event sender. The first pair of parameters defines the sender's contact. Then the sender's attributes are specified. There are three "special" contact types: dev (the sender/recipient is a device), res (the sender/recipient is a resource), ws (the sender/recipient is a "Workstation"). If no sender is specified, then two senders will be generated: one sender with "Person" type and "auth" contact type and the other sender with "Workstation" type and dnshostname contact. Only one sender can be specified;

    Примечание
    iconfalse
    titleExample:

    For the event where the sender has a VK account and meta-information is indicated: 

    --sender "vkontakte:349051292:'{\"display_name\":\"some name\",\"url\":\"some_url\",\"login\":\"some_login\"}'"

  • --receiver – the event recipient. Has the same parameters as the sender;
  • --data – the event data. The first pair of parameters defines the path to a file with the event body. Other parameters describe attributes of these data. Some of the attributes are required for some event types;
  • --mes – passing events of "Chat" class. A contact of the message sender and the message contents are specified. There can be several messages;
  • --addctx – an optional parameter. Automatically adds two senders to the event: one sender with "Person" type and "auth" contact type and the other sender with "Workstation" type and dnshostname contact type.

Examples of calling this utility can be found in the source codes of samples.
Besides, SDK samples include:

  • pluging.json file – JSON scheme of mainifest.json file, which in is included in the registation registration file for a new plugin;
  • plugin.zip file – a sample of file used for registation registration of an external plugin.

    Предупреждение
    titleImportant!

    The file contains an expired license. To use the sample file for registration of the plugin, you need to obtain a new license.