text:
/*
 * File: gevents.h
 * ---------------
 * This file defines the event types used in the StanfordCPPLib
 * graphics libraries.  The structure of this package is adapted from
 * the Java event model.
 * <include src="pictures/ClassHierarchies/GEventHierarchy-h.html">
 *
 * @version 2015/11/07
 * - added GTable TABLE_EVENT and TABLE_UPDATED
 */

#ifndef _gevents_h
#define _gevents_h

#include <string>
#include "gtable.h"
#include "gtimer.h"
#include "gwindow.h"

/*
 * Type: EventClassType
 * --------------------
 * This enumeration type defines the event classes.  The element values
 * are each a single bit and can be added or ORed together to generate
 * an event mask.  The CLICK_EVENT class responds only to
 * the MOUSE_CLICKED event type.  The ANY_EVENT class
 * selects any event.
 */
enum EventClassType {
    NULL_EVENT   = 0x000,
    ACTION_EVENT = 0x010,
    KEY_EVENT    = 0x020,
    TIMER_EVENT  = 0x040,
    WINDOW_EVENT = 0x080,
    MOUSE_EVENT  = 0x100,
    CLICK_EVENT  = 0x200,
    TABLE_EVENT  = 0x400,
    SERVER_EVENT = 0x800,
    ANY_EVENT    = 0x3F0
};

/*
 * Type: EventType
 * ---------------
 * This enumeration type defines the event types for all events.
 */
typedef enum {
    WINDOW_CLOSED    = WINDOW_EVENT + 1,
    WINDOW_RESIZED   = WINDOW_EVENT + 2,
    CONSOLE_CLOSED   = WINDOW_EVENT + 3,
    ACTION_PERFORMED = ACTION_EVENT + 1,
    MOUSE_CLICKED    = MOUSE_EVENT + 1,
    MOUSE_PRESSED    = MOUSE_EVENT + 2,
    MOUSE_RELEASED   = MOUSE_EVENT + 3,
    MOUSE_MOVED      = MOUSE_EVENT + 4,
    MOUSE_DRAGGED    = MOUSE_EVENT + 5,
    KEY_PRESSED      = KEY_EVENT + 1,
    KEY_RELEASED     = KEY_EVENT + 2,
    KEY_TYPED        = KEY_EVENT + 3,
    TIMER_TICKED     = TIMER_EVENT + 1,
    TABLE_UPDATED    = TABLE_EVENT + 1,
    TABLE_SELECTED   = TABLE_EVENT + 2,
    SERVER_REQUEST   = SERVER_EVENT + 1
} EventType;

/*
 * Type: ModifierCodes
 * -------------------
 * This enumeration type defines a set of constants used to check whether
 * modifiers are in effect.
 */
enum ModifierCodes {
    SHIFT_DOWN     = 1 << 0,
    CTRL_DOWN      = 1 << 1,
    META_DOWN      = 1 << 2,
    ALT_DOWN       = 1 << 3,
    ALT_GRAPH_DOWN = 1 << 4,
    BUTTON1_DOWN   = 1 << 5,
    BUTTON2_DOWN   = 1 << 6,
    BUTTON3_DOWN   = 1 << 7
};

/*
 * Type: KeyCodes
 * --------------
 * This type defines the names of the key codes returned in a key event.
 */
enum KeyCodes {
    BACKSPACE_KEY = 8,
    TAB_KEY = 9,
    ENTER_KEY = 10,
    CLEAR_KEY = 12,
    ESCAPE_KEY = 27,
    PAGE_UP_KEY = 33,
    PAGE_DOWN_KEY = 34,
    END_KEY = 35,
    HOME_KEY = 36,
    LEFT_ARROW_KEY = 37,
    UP_ARROW_KEY = 38,
    RIGHT_ARROW_KEY = 39,
    DOWN_ARROW_KEY = 40,
    F1_KEY = 112,
    F2_KEY = 113,
    F3_KEY = 114,
    F4_KEY = 115,
    F5_KEY = 116,
    F6_KEY = 117,
    F7_KEY = 118,
    F8_KEY = 119,
    F9_KEY = 120,
    F10_KEY = 121,
    F11_KEY = 122,
    F12_KEY = 123,
    DELETE_KEY = 127,
    HELP_KEY = 156
};

/* Forward definitions */
class GWindowEvent;
class GActionEvent;
class GMouseEvent;
class GKeyEvent;
class GTimerEvent;
class GTableEvent;
class GServerEvent;
class GObject;

/*
 * Class: GEvent
 * -------------
 * This class is the root of the hierarchy for all events.
 * <include src="pictures/ClassHierarchies/GEventHierarchy.html">
 *
 *
The standard paradigm for using GEvent is illustrated
 * by the following program, which allows the user to draw lines on the
 * graphics window:
 *
 *

 *    int main() {
 *       GWindow gw;
 *       GLine *line;
 *       cout << "This program lets the user draw lines by dragging." << endl;
 *       while (true) {
 *          GMouseEvent e = waitForEvent(MOUSE_EVENT);
 *          if (e.getEventType() == MOUSE_PRESSED) {
 *             line = new GLine(e.getX(), e.getY(), e.getX(), e.getY());
 *             gw.add(line);
 *          } else if (e.getEventType() == MOUSE_DRAGGED) {
 *             line->setEndPoint(e.getX(), e.getY());
 *          }
 *       }
 *    }
 *

 */

class GEvent {
public:

    /*
     * Friend constructor: GEvent
     * Usage: GEvent event;
     * --------------------
     * Ensures that an event is properly initialized to a null/empty event.
     */
    GEvent();

    /*
     * Method: getEventClass
     * Usage: EventClassType eventClass = e.getEventClass();
     * -----------------------------------------------------
     * Returns the enumerated type constant indicating the class of the
     * event.
     */
    EventClassType getEventClass() const;

    /*
     * Method: getEventType
     * Usage: EventType type = e.getEventType();
     * -----------------------------------------
     * Returns the enumerated type constant corresponding to the specific
     * event type.
     */
    EventType getEventType() const;

    /*
     * Method: getEventTime
     * Usage: double time = e.getEventTime();
     * --------------------------------------
     * Returns the system time in milliseconds at which the event occurred.
     * To ensure portability among systems that represent time in different
     * ways, the StanfordCPPLib packages use type double to
     * represent time, which is always encoded as the number of milliseconds
     * that have elapsed since 00:00:00 UTC on January 1, 1970, which is
     * the conventional zero point for computer-based time systems.
     */
    double getEventTime() const;

    /*
     * Method: getModifiers
     * Usage: int modifiers = e.getModifiers();
     * ----------------------------------------
     * Returns an integer whose bits indicate what modifiers are in effect.
     * To check whether the shift key is down, for example, one could use
     * the following code:
     *
     *

     *    if (e.getModifiers() & SHIFT_DOWN) ...
     *

     */
    int getModifiers() const;

    /*
     * Method: toString
     * Usage: string str = e.toString();
     * ---------------------------------
     * Converts the event to a human-readable representation of the event.
     */
    virtual std::string toString() const;

    /*
     * Method: isValid
     * Usage: if (e.isValid()) ...
     * ---------------------------
     * Returns true if the event is valid.
     */
    bool isValid();

    /* Private section */

    /**********************************************************************/
    /* Note: Everything below this point in the file is logically part    */
    /* of the implementation and should not be of interest to clients.    */
    /**********************************************************************/

    /*
     * Method: setEventTime
     * Usage: e.setEventTime(time);
     * ----------------------------
     * Sets the event time field for this event.  The event system needs
     * access to this method, but conventional clients don't.
     */
    void setEventTime(double time);

    /*
     * Method: setModifiers
     * Usage: e.setModifiers(modifiers);
     * ---------------------------------
     * Sets the modifiers field for this event.  The event system needs
     * access to this method, but conventional clients don't.
     */
    void setModifiers(int modifiers);

private:
    /*
     * Instance variables
     * ------------------
     * Implementation note: All the variables from the subclasses are included
     * in the outer class to make it possible to convert between general events
     * and the various subclasses.  By keeping all event classes the same size,
     * this design avoids any issues of slicing off parts of the data during
     * such conversions.
     */

    /* General events */
    EventClassType eventClass;
    int eventType;
    int modifiers;
    double eventTime;
    bool valid;
    std::string sourceKey;

    /* Window, mouse, and key events */
    GWindowData *gwd;

    /* Action events */
    GObject *source;
    std::string actionCommand;

    /* Mouse events */
    double x;
    double y;

    /* Key events */
    int keyChar;
    int keyCode;

    /* Server events */
    int requestID;
    std::string requestUrl;

    /* Table events */
    int row;
    int column;
    std::string value;

    /* Timer events */
    GTimerData *gtd;

    /* Friend specifications */
    friend class GActionEvent;
    friend class GKeyEvent;
    friend class GMouseEvent;
    friend class GServerEvent;
    friend class GTableEvent;
    friend class GTimerEvent;
    friend class GWindowEvent;
};

/*
 * Function: waitForClick
 * Usage: waitForClick();
 * ----------------------
 * Waits for a mouse click in any window, discarding any other events.
 * Returns the mouse event that occurred.
 */
GMouseEvent waitForClick();

/*
 * Function: waitForEvent
 * Usage: GEvent e = waitForEvent(mask);
 * -------------------------------------
 * Dismisses the process until an event occurs whose type is covered by
 * the event mask.  The mask parameter is a combination of the events of
 * interest.  For example, to wait for a mouse event or an action event,
 * clients can use the following call:
 *
 *

 *    e = waitForEvent(MOUSE_EVENT + ACTION_EVENT);
 *

 *
 * The mask parameter is optional.  If it is missing,
 * waitForEvent accepts any event.
 *
 *
As a more sophisticated example, the following code is the canonical
 * event loop for an animated application that needs to respond to mouse,
 * key, and timer events:
 *
 *

 *    GTimer timer(ANIMATION_DELAY_IN_MILLISECONDS);
 *    timer.start();
 *    while (true) {
 *       GEvent e = waitForEvent(TIMER_EVENT + MOUSE_EVENT + KEY_EVENT);
 *       switch (e.getEventClass()) {
 *        case TIMER_EVENT:
 *          takeAnimationStep();
 *          break;
 *        case MOUSE_EVENT:
 *          handleMouseEvent(GMouseEvent(e));
 *          break;
 *        case KEY_EVENT:
 *          handleKeyEvent(GKeyEvent(e));
 *          break;
 *       }
 *    }
 *

 */
GEvent waitForEvent(int mask = ANY_EVENT);

/*
 * Function: getNextEvent
 * Usage: GEvent e = getNextEvent(mask);
 * -------------------------------------
 * Checks to see if there are any events of the desired type waiting on the
 * event queue.  If so, this function returns the event in exactly the same
 * fashion as waitForEvent; if not, getNextEvent
 * returns an invalid event.  The mask parameter is optional.
 * If it is missing, getNextEvent accepts any event.
 */
GEvent getNextEvent(int mask = ANY_EVENT);

/*
 * Class: GWindowEvent
 * -------------------
 * This event subclass represents a window event.
 * Each GWindowEvent keeps track of the event type
 * (WINDOW_CLOSED, WINDOW_RESIZED) along
 * with the identity of the window.
 */
class GWindowEvent : public GEvent {
public:
    /*
     * Constructor: GWindowEvent
     * Usage: GWindowEvent windowEvent(type, gw);
     * ------------------------------------------
     * Creates a GWindowEvent using the specified parameters.
     */
    GWindowEvent(EventType type, const GWindow & gw);

    /*
     * Method: getGWindow
     * Usage: GWindow gw = e.getGWindow();
     * -----------------------------------
     * Returns the graphics window in which this event occurred.
     */
    GWindow getGWindow() const;

    /*
     * Method: toString
     * Usage: string str = e.toString();
     * ---------------------------------
     * Converts the event to a human-readable representation of the event.
     */
    std::string toString() const;

    /* Private section */
    GWindowEvent();
    GWindowEvent(GEvent e);
};

/*
 * Class: GActionEvent
 * -------------------
 * This event subclass represents an action event.
 * Action events are generated by the classes in the
 * GInteractor
 * hierarchy.  As an example, the following program displays
 * a button that, when pushed, generates the message
 * “Please do not press this button again”
 * (with thanks to Douglas Adams’s Hitchhiker’s
 * Guide to the Galaxy):
 *
 *

 *    int main() {
 *       GWindow gw;
 *       GButton *button = new GButton("RED");
 *       gw.addToRegion(button, "SOUTH");
 *       while (true) {
 *          GEvent e = waitForEvent(ACTION_EVENT | CLICK_EVENT);
 *          if (e.getEventType() == MOUSE_CLICKED) break;
 *          cout << "Please do not press this button again." << endl;
 *       }
 *       return 0;
 *    }
 *

 */
class GActionEvent : public GEvent {
public:
    /*
     * Constructor: GActionEvent
     * Usage: GActionEvent actionEvent(type, source, actionCommand);
     * -------------------------------------------------------------
     * Creates a GActionEvent using the specified parameters.
     */
    GActionEvent(EventType type, GObject *source, std::string actionCommand);

    /*
     * Method: getSource
     * Usage: GObject *gobj = e.getSource();
     * -------------------------------------
     * Returns a pointer to the GObject that generated this event.
     */
    GObject *getSource() const;

    /*
     * Method: getActionCommand
     * Usage: string cmd = e.getActionCommand();
     * -----------------------------------------
     * Returns the action command associated with this event.
     */
    std::string getActionCommand() const;

    /*
     * Method: toString
     * Usage: string str = e.toString();
     * ---------------------------------
     * Converts the event to a human-readable representation of the event.
     */
    std::string toString() const;

    /* Private section */
    GActionEvent();
    GActionEvent(GEvent e);
};

/*
 * Class: GMouseEvent
 * ------------------
 * This event subclass represents a mouse event.  Each mouse event
 * records the event type (MOUSE_PRESSED,
 * MOUSE_RELEASED, MOUSE_CLICKED,
 * MOUSE_MOVED, MOUSE_DRAGGED) along
 * with the coordinates of the event.  Clicking the mouse generates
 * three events in the following order: MOUSE_PRESSED,
 * MOUSE_RELEASED, MOUSE_CLICKED.
 *
 *
As an example, the following program uses mouse events to let
 * the user draw rectangles on the graphics window.  The only
 * complexity in this code is the use of the library functions
 * min and abs to ensure that the
 * dimensions of the rectangle are positive.
 *
 *

 *    int main() {
 *       GWindow gw;
 *       cout << "This program lets the user draw rectangles." << endl;
 *       GRect *rect;
 *       double startX;
 *       double startY;
 *       while (true) {
 *          GMouseEvent e = waitForEvent();
 *          if (e.getEventType() == MOUSE_PRESSED) {
 *             startX = e.getX();
 *             startY = e.getY();
 *             rect = new GRect(startX, startY, 0, 0);
 *             rect->setFilled(true);
 *             gw.add(rect);
 *          } else if (e.getEventType() == MOUSE_DRAGGED) {
 *             double x = min(e.getX(), startX);
 *             double y = min(e.getY(), startY);
 *             double width = abs(e.getX() - startX);
 *             double height = abs(e.getY() - startY);
 *             rect->setBounds(x, y, width, height);
 *          }
 *       }
 *    }
 *

 */

class GMouseEvent : public GEvent {
public:
    /*
     * Constructor: GMouseEvent
     * Usage: GMouseEvent mouseEvent(type, gw, x, y);
     * ----------------------------------------------
     * Creates a GMouseEvent using the specified parameters.
     */
    GMouseEvent(EventType type, const GWindow & gw, double x, double y);

    /*
     * Method: getGWindow
     * Usage: GWindow gw = e.getGWindow();
     * -----------------------------------
     * Returns the graphics window in which this event occurred.
     */
    GWindow getGWindow() const;

    /*
     * Method: getX
     * Usage: double x = getX();
     * -------------------------
     * Returns the x coordinate at which the event occurred relative
     * to the window origin at the upper left corner of the window.
     */
    double getX() const;

    /*
     * Method: getY
     * Usage: double y = getY();
     * -------------------------
     * Returns the y coordinate at which the event occurred relative
     * to the window origin at the upper left corner of the window.
     */
    double getY() const;

    /*
     * Returns true if the user pressed the left mouse button.
     */
    bool isLeftClick() const;

    /*
     * Returns true if the user pressed the right mouse button.
     */
    bool isRightClick() const;

    /*
     * Returns true if the user pressed the middle mouse button.
     */
    bool isMiddleClick() const;

    /*
     * Method: toString
     * Usage: string str = e.toString();
     * ---------------------------------
     * Converts the event to a human-readable representation of the event.
     */
    std::string toString() const;

    /* Private section */
    GMouseEvent();
    GMouseEvent(GEvent e);
};

/*
 * Class: GKeyEvent
 * ----------------
 * This event subclass represents a key event.  Each key event records
 * the event type along with two representations of the key.  The
 * getKeyChar function is more generally useful and
 * returns the character after taking into account modifier keys.
 * The getKeyCode function returns an integer identifying
 * the key, which can be a function key as well as a standard key.
 * The codes return by getKeyCode are listed in the
 * KeyCodes enumeration.
 */
class GKeyEvent : public GEvent {
public:
    /*
     * Constructor: GKeyEvent
     * Usage: GKeyEvent keyEvent(type, gw, keyChar, keyCode);
     * ------------------------------------------------------
     * Creates a GKeyEvent using the specified parameters.
     */
    GKeyEvent(EventType type, const GWindow & gw, int keyChar, int keyCode);

    /*
     * Method: getGWindow
     * Usage: GWindow gw = e.getGWindow();
     * -----------------------------------
     * Returns the graphics window in which this event occurred.
     */
    GWindow getGWindow() const;

    /*
     * Method: getKeyChar
     * Usage: char ch = e.getKeyChar();
     * --------------------------------
     * Returns the character represented by the keystroke, taking the modifier
     * keys into account.  For example, if the user types the 'a'
     * key with the shift key down, getKeyChar will return
     * 'A'.  If the key code in the event does not correspond
     * to a character, getKeyChar returns the null character.
     */
    char getKeyChar() const;

    /*
     * Method: getKeyCode
     * Usage: int key = getKeyCode();
     * ------------------------------
     * Returns the integer code associated with the key in the event.
     */
    int getKeyCode() const;

    /*
     * Method: toString
     * Usage: string str = e.toString();
     * ---------------------------------
     * Converts the event to a human-readable representation of the event.
     */
    std::string toString() const;

    /* Private section */
    GKeyEvent();
    GKeyEvent(GEvent e);
};

/*
 * Class: GTimerEvent
 * ------------------
 * This event subclass represents a timer event.  Timer events are
 * generated by a GTimer
 * object, which produces a new event at a fixed interval measured in
 * milliseconds.  As an example, the following program generates a
 * timer event every two seconds, stopping when the user clicks
 * somewhere in the window:
 *
 *

 *    int main() {
 *       cout << "This program generates timer events." << endl;
 *       GTimer timer(2000);
 *       timer.start();
 *       while (true) {
 *          GEvent e = waitForEvent(CLICK_EVENT | TIMER_EVENT);
 *          if (e.getEventType() == MOUSE_CLICKED) break;
 *          cout << "Timer ticked" << endl;
 *       }
 *       return 0;
 *    }
 *

 */
class GTimerEvent : public GEvent {
public:
    /*
     * Constructor: GTimerEvent
     * Usage: GTimerEvent timerEvent(type, timer);
     * -------------------------------------------
     * Creates a GTimerEvent for the specified timer.
     */
    GTimerEvent(EventType type, const GTimer & timer);

    /*
     * Method: getGTimer
     * Usage: GTimer timer = e.getGTimer();
     * ------------------------------------
     * Returns the timer that generated this event.
     */
    GTimer getGTimer() const;

    /*
     * Method: toString
     * Usage: string str = e.toString();
     * ---------------------------------
     * Converts the event to a human-readable representation of the event.
     */
    std::string toString() const;

    /* Private section */
    GTimerEvent();
    GTimerEvent(GEvent e);
};

class GTableEvent : public GEvent {
public:
    /*
     * Constructor: GTableEvent
     * Usage: GTableEvent tableEvent(type);
     * -------------------------------------------
     * Creates a GTableEvent for the specified table.
     */
    GTableEvent(EventType type);

//    /*
//     * Method: getGTable
//     * Usage: GTable table = e.getGTable();
//     * ------------------------------------
//     * Returns the table that generated this event.
//     */
//    GTable getGTable() const;

    int getColumn() const;
    int getRow() const;
    std::string getValue() const;

    void setLocation(int row, int column);
    void setValue(std::string value);

    /*
     * Method: toString
     * Usage: string str = e.toString();
     * ---------------------------------
     * Converts the event to a human-readable representation of the event.
     */
    std::string toString() const;

    /* Private section */
    GTableEvent();
    GTableEvent(GEvent e);
};

class GServerEvent : public GEvent {
public:
    /*
     * Constructor: GServerEvent
     * Usage: GServerEvent serverEvent(type);
     * --------------------------------------
     * Creates a GServerEvent with the specified type.
     */
    GServerEvent(EventType type, int requestID, const std::string& requestUrl);

    /*
     * Returns the request ID sent by the server to disambiguate messages.
     */
    int getRequestID() const;

    /*
     * Returns the URL of the request that the web client wants to fetch,
     * such as "/foo/bar/baz.txt".
     */
    std::string getRequestURL() const;

    /*
     * Method: toString
     * Usage: string str = e.toString();
     * ---------------------------------
     * Converts the event to a human-readable representation of the event.
     */
    std::string toString() const;

    /* Private section */
    GServerEvent();
    GServerEvent(GEvent e);
};

#include "private/init.h"   // ensure that Stanford C++ lib is initialized

#endif


text:
/**
 * Created by programulya on 4/20/15.
 */

var app = app || {};

(function () {
    'use strict';

    app.Utils = {
        store: function (namespace, data) {
            if (data) {
                return localStorage.setItem(namespace, JSON.stringify(data));
            }

            var store = localStorage.getItem(namespace);
            return (store && JSON.parse(store)) || [];
        }
    };
})();

redpajama_set_name: RedPajamaGithub


text:
package com.helger.html.hc.html.textlevel;

/**
 * Represents an HTML <SPAN> element
 *
 * @author Philip Helger
 */
public class HCSpan extends AbstractHCSpan <HCSpan>
{
  /**
   * Create a new SPAN element
   */
  public HCSpan ()
  {
    super ();
  }
}


text:
name             'fastflow'
maintainer       'YOUR_COMPANY_NAME'
maintainer_email 'YOUR_EMAIL'
license          'All rights reserved'
description      'Installs/Configures fastflow'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version          '2.0.0'

depends "apt"
depends "java"
depends "build-essential"
depends "openssl"
depends "ark"
depends "subversion"


text:
package org.jetbrains.plugins.scala.lang.actions.editor.enter

import org.jetbrains.plugins.scala.extensions.StringExt
import org.jetbrains.plugins.scala.lang.actions.editor.enter.scala3.EditorStates.reservedDebugNames

import scala.collection.mutable

package object scala3 {

  case class EditorState private(text: String, textToType: String) {
    def withTransformedText(f: String => String): EditorState = EditorState(f(text), textToType)
  }
  object EditorState {
    def apply(text: String, textToType: String): EditorState =
      new EditorState(text.withNormalizedSeparator, textToType.withNormalizedSeparator)

    def apply(text: String, textToType: TypeText): EditorState =
      new EditorState(text, textToType.text)
  }

  case class EditorStates private(debugName: Option[String], states: Seq[EditorState]) {
    debugName.foreach { name =>
      reservedDebugNames.synchronized {
        if (reservedDebugNames.contains(name))
          throw new AssertionError(s"editor states debug name is not unique: '$name'")
        else
          reservedDebugNames += name
      }
    }
  }
  object EditorStates {
    private val reservedDebugNames = mutable.HashSet.empty[String]

    def apply(debugName: String, states: Seq[(String, TypeText)])
             (implicit d: DummyImplicit): EditorStates =
      new EditorStates(Some(debugName), states.map(t => EditorState(t._1, t._2)))

    def apply(debugName: String, states: Seq[EditorState])
             (implicit d: DummyImplicit, d2: DummyImplicit): EditorStates =
      new EditorStates(Some(debugName), states)

    def apply(states: (String, TypeText)*)
             (implicit d: DummyImplicit): EditorStates =
      new EditorStates(None, states.map(t => EditorState(t._1, t._2)))

    def apply(debugName: String, before: String, textToType: TypeText, after: String): EditorStates = {
      val states: Seq[EditorState] = Seq(EditorState(before, textToType), EditorState(after, ""))
      new EditorStates(Some(debugName), states)
    }
  }

  case class TypeText(text: String)
  object TypeText {
    val Enter: TypeText = TypeText("\n")
    val Ignored: TypeText = TypeText("")
  }
}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<title>
Basit Örnek
</title>

Basit Örnek

This is a simple example add-on that you can copy and use as the basis of a new add-on that actually does something useful.

Aşağıdakileri sağlar:

Üst Düzey Menü

Üst düzey 'Araçlar' menüsü altındaki bir menü öğesi.

Sağ Tık Menüsü

Mesajlar için etkinleştirilmiş bir sağ tık menü öğesi.

Durum Paneli

Temel bir durum paneli.

ZAP API Component

An API component that adds an action endpoint.

Help file

This help file.


text:
package com.cloudera.science.ml.parallel.records;

import org.apache.crunch.PCollection;

import com.cloudera.science.ml.core.records.Record;
import com.cloudera.science.ml.core.records.Spec;

public class Records {
  private final Spec spec;
  private final PCollection<Record> records;

  public Records(PCollection<Record> records, Spec spec) {
    this.records = records;
    this.spec = spec;
  }

  public PCollection<Record> get() {
    return records;
  }

  public Spec getSpec() {
    return spec;
  }
}


text:
module CRM
  class Tag

    def self.boolean(record, tag, label, &block)
      new(record, :boolean, tag, label).value(&block)
    end

    def self.text(record, tag, label, &block)
      new(record, :text, tag, label).value(&block)
    end

    def self.date(record, tag, label, &block)
      new(record, :date, tag, label).value(&block)
    end

    attr_reader :record, :type, :tag, :label

    def initialize(record, type, tag, label)
      @record = record
      @type   = type
      @tag    = tag
      @label  = label
    end

    def value(&block)
      field(tag, label).send(type)
    rescue ArgumentError
      if block_given?
        yield
      else
        default_value
      end
    end

    private

    def field(tag, label)
      record.custom_fields.find(tag_missing) do |field|
        field.label == label && field.tag == tag
      end
    end

    def default_value
      nil
    end

    def tag_missing
      -> { raise ArgumentError }
    end
  end
end


text:
using System.Net;
using System.Text.Json;
using Azure.Core;

namespace Azure.ResourceManager.Media.Models
{
    public partial class IPRange : IUtf8JsonSerializable
    {
        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
        {
            writer.WriteStartObject();
            if (Optional.IsDefined(Name))
            {
                writer.WritePropertyName("name");
                writer.WriteStringValue(Name);
            }
            if (Optional.IsDefined(Address))
            {
                writer.WritePropertyName("address");
                writer.WriteStringValue(Address.ToString());
            }
            if (Optional.IsDefined(SubnetPrefixLength))
            {
                writer.WritePropertyName("subnetPrefixLength");
                writer.WriteNumberValue(SubnetPrefixLength.Value);
            }
            writer.WriteEndObject();
        }

        internal static IPRange DeserializeIPRange(JsonElement element)
        {
            Optional<string> name = default;
            Optional<IPAddress> address = default;
            Optional<int> subnetPrefixLength = default;
            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("address"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    address = IPAddress.Parse(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("subnetPrefixLength"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    subnetPrefixLength = property.Value.GetInt32();
                    continue;
                }
            }
            return new IPRange(name.Value, address.Value, Optional.ToNullable(subnetPrefixLength));
        }
    }
}


text:
import { graphql, commitMutation } from 'react-relay';

import type {
  RecordSourceSelectorProxy,
  RelayEnvironment,
  SelectorData,
} from 'react-relay';

import type {
  DeleteBucketMutationVariables,
  DeleteBucketMutationResponse,
} from './__generated__/DeleteBucketMutation.graphql';

const mutation = graphql`
  mutation DeleteBucketMutation($id: ID!) {
    deleteBucket(idValue: $id) {
      isOk
    }
  }
`;

export default (
  updater?: ?(store: RecordSourceSelectorProxy, data: SelectorData) => void,
  optimisticUpdater?: ?(store: RecordSourceSelectorProxy) => void,
  onCompleted?: ?(response: ?DeleteBucketMutationResponse, errors: ?[Error]) => void,
) => (environment: RelayEnvironment) => (variables: DeleteBucketMutationVariables) => {
  const optimisticResponse = {
    deleteBucket: {
      ok: true,
    },
  };
  commitMutation(environment, {
    mutation,
    variables,
    updater,
    optimisticResponse,
    optimisticUpdater,
    onCompleted,
  });
};


text:
<?php
print($doc_type);
$_CI =& get_instance();
?>

  <link rel="stylesheet" href="http://www.mediagate.it/future/application/views/tema/css/alloy-bootstrap/bootstrap-2.3.2.min.css">

 <?php

    if(isset($meta_tags) && is_array($meta_tags))
      foreach ($meta_tags as $tag)
          print(html_entity_decode($tag)."\n");

    /* Carica fogli di stile e librerie javascript, comuni e specifiche */
    if(isset($js_headers) && is_array($js_headers))
      foreach ($js_headers as $script)
          print(html_entity_decode($script)."\n");
  ?>

  <link rel="stylesheet" href="http://www.mediagate.it/future/application/views/tema/js/owl-carousel/assets/owl.carousel.css">
  <link rel="stylesheet" href="http://www.mediagate.it/future/application/views/tema/js/owl-carousel/assets/owl.theme.default.css">

  <title><?php print($nome_sito);?></title>

<body id='<?php print($page_tag);?>' class='homepage'>

    <?php print($header);?>

          <div data-dot="
In Primo Piano
">

          <div data-dot="
Allestimento
">

          <div data-dot="
Iniziative Speciali
">

          <div data-dot="
Help Center
">

          <div data-dot="
Procedure
">

Iniziative e novità

My HomePage

            <?php $_CI->buildCustomTextBlock('span','benvenuto','environment_is_dev','environment_is_dev');?>

Il mio Punto di Vendita

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

              <button type="submit" class="btn btn-default">X</button>

Periodo Contabile

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

              <button type="submit" class="btn btn-default">X</button>

Le mie Locandine

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

              <button type="submit" class="btn btn-default">X</button>

Superenalotto

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

              <button type="submit" class="btn btn-default">X</button>

  <?php print($footer);?>


text:
class SrsFastStream;
class SrsBuffer;
class SrsAmf0Any;
class SrsMessageHeader;
class SrsChunkStream;
class SrsSharedPtrMessage;

class SrsProtocol;
class ISrsProtocolReader;
class ISrsProtocolReadWriter;
class SrsCreateStreamPacket;
class SrsFMLEStartPacket;
class SrsPublishPacket;
class SrsOnMetaDataPacket;
class SrsPlayPacket;
class SrsCommonMessage;
class SrsPacket;
class SrsAmf0Object;
class IMergeReadHandler;
class SrsCallPacket;

// The amf0 command message, command name macros
#define RTMP_AMF0_COMMAND_CONNECT               "connect"
#define RTMP_AMF0_COMMAND_CREATE_STREAM         "createStream"
#define RTMP_AMF0_COMMAND_CLOSE_STREAM          "closeStream"
#define RTMP_AMF0_COMMAND_PLAY                  "play"
#define RTMP_AMF0_COMMAND_PAUSE                 "pause"
#define RTMP_AMF0_COMMAND_ON_BW_DONE            "onBWDone"
#define RTMP_AMF0_COMMAND_ON_STATUS             "onStatus"
#define RTMP_AMF0_COMMAND_RESULT                "_result"
#define RTMP_AMF0_COMMAND_ERROR                 "_error"
#define RTMP_AMF0_COMMAND_RELEASE_STREAM        "releaseStream"
#define RTMP_AMF0_COMMAND_FC_PUBLISH            "FCPublish"
#define RTMP_AMF0_COMMAND_UNPUBLISH             "FCUnpublish"
#define RTMP_AMF0_COMMAND_PUBLISH               "publish"
#define RTMP_AMF0_DATA_SAMPLE_ACCESS            "|RtmpSampleAccess"

// The signature for packets to client.
#define RTMP_SIG_FMS_VER                        "3,5,3,888"
#define RTMP_SIG_AMF0_VER                       0
#define RTMP_SIG_CLIENT_ID                      "ASAICiss"

// The onStatus consts.
#define StatusLevel                             "level"
#define StatusCode                              "code"
#define StatusDescription                       "description"
#define StatusDetails                           "details"
#define StatusClientId                          "clientid"
// The status value
#define StatusLevelStatus                       "status"
// The status error
#define StatusLevelError                        "error"
// The code value
#define StatusCodeConnectSuccess                "NetConnection.Connect.Success"
#define StatusCodeConnectRejected               "NetConnection.Connect.Rejected"
#define StatusCodeStreamReset                   "NetStream.Play.Reset"
#define StatusCodeStreamStart                   "NetStream.Play.Start"
#define StatusCodeStreamPause                   "NetStream.Pause.Notify"
#define StatusCodeStreamUnpause                 "NetStream.Unpause.Notify"
#define StatusCodePublishStart                  "NetStream.Publish.Start"
#define StatusCodeDataStart                     "NetStream.Data.Start"
#define StatusCodeUnpublishSuccess              "NetStream.Unpublish.Success"

// The decoded message payload.
// @remark we seperate the packet from message,
//        for the packet focus on logic and domain data,
//        the message bind to the protocol and focus on protocol, such as header.
//         we can merge the message and packet, using OOAD hierachy, packet extends from message,
//         it's better for me to use components -- the message use the packet as payload.
class SrsPacket
{
public:
    SrsPacket();
    virtual ~SrsPacket();
public:
    // Covert packet to common message.
    virtual srs_error_t to_msg(SrsCommonMessage* msg, int stream_id);
public:
    // The subpacket can override this encode,
    // For example, video and audio will directly set the payload withou memory copy,
    // other packet which need to serialize/encode to bytes by override the
    // get_size and encode_packet.
    virtual srs_error_t encode(int& size, char*& payload);
// Decode functions for concrete packet to override.
public:
    // The subpacket must override to decode packet from stream.
    // @remark never invoke the super.decode, it always failed.
    virtual srs_error_t decode(SrsBuffer* stream);
// Encode functions for concrete packet to override.
public:
    // The cid(chunk id) specifies the chunk to send data over.
    // Generally, each message perfer some cid, for example,
    // all protocol control messages perfer RTMP_CID_ProtocolControl,
    // SrsSetWindowAckSizePacket is protocol control message.
    virtual int get_prefer_cid();
    // The subpacket must override to provide the right message type.
    // The message type set the RTMP message type in header.
    virtual int get_message_type();
protected:
    // The subpacket can override to calc the packet size.
    virtual int get_size();
    // The subpacket can override to encode the payload to stream.
    // @remark never invoke the super.encode_packet, it always failed.
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// The protocol provides the rtmp-message-protocol services,
// To recv RTMP message from RTMP chunk stream,
// and to send out RTMP message over RTMP chunk stream.
class SrsProtocol
{
private:
    class AckWindowSize
    {
    public:
        uint32_t window;
        // number of received bytes.
        int64_t nb_recv_bytes;
        // previous responsed sequence number.
        uint32_t sequence_number;

        AckWindowSize();
    };
// For peer in/out
private:
    // The underlayer socket object, send/recv bytes.
    ISrsProtocolReadWriter* skt;
    // The requests sent out, used to build the response.
    // key: transactionId
    // value: the request command name
    std::map<double, std::string> requests;
// For peer in
private:
    // The chunk stream to decode RTMP messages.
    std::map<int, SrsChunkStream*> chunk_streams;
    // Cache some frequently used chunk header.
    // cs_cache, the chunk stream cache.
    SrsChunkStream** cs_cache;
    // The bytes buffer cache, recv from skt, provide services for stream.
    SrsFastStream* in_buffer;
    // The input chunk size, default to 128, set by peer packet.
    int32_t in_chunk_size;
    // The input ack window, to response acknowledge to peer,
    // For example, to respose the encoder, for server got lots of packets.
    AckWindowSize in_ack_size;
    // The output ack window, to require peer to response the ack.
    AckWindowSize out_ack_size;
    // The buffer length set by peer.
    int32_t in_buffer_length;
    // Whether print the protocol level debug info.
    // Generally we print the debug info when got or send first A/V packet.
    bool show_debug_info;
    // Whether auto response when recv messages.
    // default to true for it's very easy to use the protocol stack.
    bool auto_response_when_recv;
    // When not auto response message, manual flush the messages in queue.
    std::vector<SrsPacket*> manual_response_queue;
// For peer out
private:
    // Cache for multiple messages send,
    // initialize to iovec[SRS_CONSTS_IOVS_MAX] and realloc when consumed,
    // it's ok to realloc the iovs cache, for all ptr is ok.
    iovec* out_iovs;
    int nb_out_iovs;
    // The output header cache.
    // used for type0, 11bytes(or 15bytes with extended timestamp) header.
    // or for type3, 1bytes(or 5bytes with extended timestamp) header.
    // The c0c3 caches must use unit SRS_CONSTS_RTMP_MAX_FMT0_HEADER_SIZE bytes.
    //
    // @remark, the c0c3 cache cannot be realloc.
    // To allocate it in heap to make VS2015 happy.
    char* out_c0c3_caches;
    // Whether warned user to increase the c0c3 header cache.
    bool warned_c0c3_cache_dry;
    // The output chunk size, default to 128, set by config.
    int32_t out_chunk_size;
public:
    SrsProtocol(ISrsProtocolReadWriter* io);
    virtual ~SrsProtocol();
public:
    // Set the auto response message when recv for protocol stack.
    // @param v, whether auto response message when recv message.
    virtual void set_auto_response(bool v);
    // Flush for manual response when the auto response is disabled
    // by set_auto_response(false), we default use auto response, so donot
    // need to call this api(the protocol sdk will auto send message).
    // @see the auto_response_when_recv and manual_response_queue.
    virtual srs_error_t manual_response_flush();
public:
#ifdef SRS_PERF_MERGED_READ
    // To improve read performance, merge some packets then read,
    // When it on and read small bytes, we sleep to wait more data.,
    // that is, we merge some data to read together.
    // @param v true to ename merged read.
    // @param handler the handler when merge read is enabled.
    virtual void set_merge_read(bool v, IMergeReadHandler* handler);
    // Create buffer with specifeid size.
    // @param buffer the size of buffer.
    // @remark when MR(SRS_PERF_MERGED_READ) disabled, always set to 8K.
    // @remark when buffer changed, the previous ptr maybe invalid.
    virtual void set_recv_buffer(int buffer_size);
#endif
public:
    // To set/get the recv timeout in srs_utime_t.
    // if timeout, recv/send message return ERROR_SOCKET_TIMEOUT.
    virtual void set_recv_timeout(srs_utime_t tm);
    virtual srs_utime_t get_recv_timeout();
    // To set/get the send timeout in srs_utime_t.
    // if timeout, recv/send message return ERROR_SOCKET_TIMEOUT.
    virtual void set_send_timeout(srs_utime_t tm);
    virtual srs_utime_t get_send_timeout();
    // Get recv/send bytes.
    virtual int64_t get_recv_bytes();
    virtual int64_t get_send_bytes();
public:
    // Set the input default ack size. This is generally set by the message from peer,
    // but for some encoder, it never send the ack message while it default to a none zone size.
    // This will cause the encoder to block after publishing some messages to server,
    // because it wait for server to send acknowledge, but server default to 0 which means no need
    // To ack encoder. We can change the default input ack size. We will always response the
    // ack size whatever the encoder set or not.
    virtual srs_error_t set_in_window_ack_size(int ack_size);
public:
    // Recv a RTMP message, which is bytes oriented.
    // user can use decode_message to get the decoded RTMP packet.
    // @param pmsg, set the received message,
    //       always NULL if error,
    //       NULL for unknown packet but return success.
    //       never NULL if decode success.
    // @remark, drop message when msg is empty or payload length is empty.
    virtual srs_error_t recv_message(SrsCommonMessage** pmsg);
    // Decode bytes oriented RTMP message to RTMP packet,
    // @param ppacket, output decoded packet,
    //       always NULL if error, never NULL if success.
    // @return error when unknown packet, error when decode failed.
    virtual srs_error_t decode_message(SrsCommonMessage* msg, SrsPacket** ppacket);
    // Send the RTMP message and always free it.
    // user must never free or use the msg after this method,
    // For it will always free the msg.
    // @param msg, the msg to send out, never be NULL.
    // @param stream_id, the stream id of packet to send over, 0 for control message.
    virtual srs_error_t send_and_free_message(SrsSharedPtrMessage* msg, int stream_id);
    // Send the RTMP message and always free it.
    // user must never free or use the msg after this method,
    // For it will always free the msg.
    // @param msgs, the msgs to send out, never be NULL.
    // @param nb_msgs, the size of msgs to send out.
    // @param stream_id, the stream id of packet to send over, 0 for control message.
    virtual srs_error_t send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, int stream_id);
    // Send the RTMP packet and always free it.
    // user must never free or use the packet after this method,
    // For it will always free the packet.
    // @param packet, the packet to send out, never be NULL.
    // @param stream_id, the stream id of packet to send over, 0 for control message.
    virtual srs_error_t send_and_free_packet(SrsPacket* packet, int stream_id);
public:
    // Expect a specified message, drop others util got specified one.
    // @pmsg, user must free it. NULL if not success.
    // @ppacket, user must free it, which decode from payload of message. NULL if not success.
    // @remark, only when success, user can use and must free the pmsg and ppacket.
    // For example:
    //          SrsCommonMessage* msg = NULL;
    //          SrsConnectAppResPacket* pkt = NULL;
    //          if ((ret = protocol->expect_message<SrsConnectAppResPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) {
    //              return ret;
    //          }
    //          // Use then free msg and pkt
    //          srs_freep(msg);
    //          srs_freep(pkt);
    // user should never recv message and convert it, use this method instead.
    // if need to set timeout, use set timeout of SrsProtocol.
    template<class T>
    srs_error_t expect_message(SrsCommonMessage** pmsg, T** ppacket)
    {
        *pmsg = NULL;
        *ppacket = NULL;

        srs_error_t err = srs_success;

        while (true) {
            SrsCommonMessage* msg = NULL;
            if ((err = recv_message(&msg)) != srs_success) {
                return srs_error_wrap(err, "recv message");
            }

            SrsPacket* packet = NULL;
            if ((err = decode_message(msg, &packet)) != srs_success) {
                srs_freep(msg);
                srs_freep(packet);
                return srs_error_wrap(err, "decode message");
            }

            T* pkt = dynamic_cast<T*>(packet);
            if (!pkt) {
                srs_freep(msg);
                srs_freep(packet);
                continue;
            }

            *pmsg = msg;
            *ppacket = pkt;
            break;
        }

        return err;
    }
private:
    // Send out the messages, donot free it,
    // The caller must free the param msgs.
    virtual srs_error_t do_send_messages(SrsSharedPtrMessage** msgs, int nb_msgs);
    // Send iovs. send multiple times if exceed limits.
    virtual srs_error_t do_iovs_send(iovec* iovs, int size);
    // The underlayer api for send and free packet.
    virtual srs_error_t do_send_and_free_packet(SrsPacket* packet, int stream_id);
    // The imp for decode_message
    virtual srs_error_t do_decode_message(SrsMessageHeader& header, SrsBuffer* stream, SrsPacket** ppacket);
    // Recv bytes oriented RTMP message from protocol stack.
    // return error if error occur and nerver set the pmsg,
    // return success and pmsg set to NULL if no entire message got,
    // return success and pmsg set to entire message if got one.
    virtual srs_error_t recv_interlaced_message(SrsCommonMessage** pmsg);
    // Read the chunk basic header(fmt, cid) from chunk stream.
    // user can discovery a SrsChunkStream by cid.
    virtual srs_error_t read_basic_header(char& fmt, int& cid);
    // Read the chunk message header(timestamp, payload_length, message_type, stream_id)
    // From chunk stream and save to SrsChunkStream.
    virtual srs_error_t read_message_header(SrsChunkStream* chunk, char fmt);
    // Read the chunk payload, remove the used bytes in buffer,
    // if got entire message, set the pmsg.
    virtual srs_error_t read_message_payload(SrsChunkStream* chunk, SrsCommonMessage** pmsg);
    // When recv message, update the context.
    virtual srs_error_t on_recv_message(SrsCommonMessage* msg);
    // When message sentout, update the context.
    virtual srs_error_t on_send_packet(SrsMessageHeader* mh, SrsPacket* packet);
private:
    // Auto response the ack message.
    virtual srs_error_t response_acknowledgement_message();
    // Auto response the ping message.
    virtual srs_error_t response_ping_message(int32_t timestamp);
private:
    virtual void print_debug_info();
};

// incoming chunk stream maybe interlaced,
// Use the chunk stream to cache the input RTMP chunk streams.
class SrsChunkStream
{
public:
    // Represents the basic header fmt,
    // which used to identify the variant message header type.
    char fmt;
    // Represents the basic header cid,
    // which is the chunk stream id.
    int cid;
    // Cached message header
    SrsMessageHeader header;
    // Whether the chunk message header has extended timestamp.
    bool extended_timestamp;
    // The partially read message.
    SrsCommonMessage* msg;
    // Decoded msg count, to identify whether the chunk stream is fresh.
    int64_t msg_count;
public:
    SrsChunkStream(int _cid);
    virtual ~SrsChunkStream();
};

// The original request from client.
class SrsRequest
{
public:
    // The client ip.
    std::string ip;
public:
    // The tcUrl: rtmp://request_vhost:port/app/stream
    // support pass vhost in query string, such as:
    //    rtmp://ip:port/app?vhost=request_vhost/stream
    //    rtmp://ip:port/app...vhost...request_vhost/stream
    std::string tcUrl;
    std::string pageUrl;
    std::string swfUrl;
    double objectEncoding;
// The data discovery from request.
public:
    // Discovery from tcUrl and play/publish.
    std::string schema;
    // The vhost in tcUrl.
    std::string vhost;
    // The host in tcUrl.
    std::string host;
    // The port in tcUrl.
    int port;
    // The app in tcUrl, without param.
    std::string app;
    // The param in tcUrl(app).
    std::string param;
    // The stream in play/publish
    std::string stream;
    // For play live stream,
    // used to specified the stop when exceed the duration.
    // in srs_utime_t.
    srs_utime_t duration;
    // The token in the connect request,
    // used for edge traverse to origin authentication,
    // @see https://github.com/ossrs/srs/issues/104
    SrsAmf0Object* args;
public:
    SrsRequest();
    virtual ~SrsRequest();
public:
    // Deep copy the request, for source to use it to support reload,
    // For when initialize the source, the request is valid,
    // When reload it, the request maybe invalid, so need to copy it.
    virtual SrsRequest* copy();
    // update the auth info of request,
    // To keep the current request ptr is ok,
    // For many components use the ptr of request.
    virtual void update_auth(SrsRequest* req);
    // Get the stream identify, vhost/app/stream.
    virtual std::string get_stream_url();
    // To strip url, user must strip when update the url.
    virtual void strip();
public:
    // Transform it as HTTP request.
    virtual SrsRequest* as_http();
public:
    // The protocol of client:
    //      rtmp, Adobe RTMP protocol.
    //      flv, HTTP-FLV protocol.
    //      flvs, HTTPS-FLV protocol.
    std::string protocol;
};

// The response to client.
class SrsResponse
{
public:
    // The stream id to response client createStream.
    int stream_id;
public:
    SrsResponse();
    virtual ~SrsResponse();
};

// The rtmp client type.
enum SrsRtmpConnType
{
    SrsRtmpConnUnknown = 0x0000,
    // All players.
    SrsRtmpConnPlay = 0x0100,
    SrsHlsPlay = 0x0101,
    SrsFlvPlay = 0x0102,
    SrsRtcConnPlay = 0x0110,
    SrsSrtConnPlay = 0x0120,
    // All publishers.
    SrsRtmpConnFMLEPublish = 0x0200,
    SrsRtmpConnFlashPublish = 0x0201,
    SrsRtmpConnHaivisionPublish = 0x0202,
    SrsRtcConnPublish = 0x0210,
    SrsSrtConnPublish = 0x0220,
};
std::string srs_client_type_string(SrsRtmpConnType type);
bool srs_client_type_is_publish(SrsRtmpConnType type);

// store the handshake bytes,
// For smart switch between complex and simple handshake.
class SrsHandshakeBytes
{
public:
    // For RTMP proxy, the real IP.
    uint32_t proxy_real_ip;
    // [1+1536]
    char* c0c1;
    // [1+1536+1536]
    char* s0s1s2;
    // [1536]
    char* c2;
public:
    SrsHandshakeBytes();
    virtual ~SrsHandshakeBytes();
public:
    virtual void dispose();
public:
    virtual srs_error_t read_c0c1(ISrsProtocolReader* io);
    virtual srs_error_t read_s0s1s2(ISrsProtocolReader* io);
    virtual srs_error_t read_c2(ISrsProtocolReader* io);
    virtual srs_error_t create_c0c1();
    virtual srs_error_t create_s0s1s2(const char* c1 = NULL);
    virtual srs_error_t create_c2();
};

// The information return from RTMP server.
struct SrsServerInfo
{
    std::string ip;
    std::string sig;
    int pid;
    int cid;
    int major;
    int minor;
    int revision;
    int build;

    SrsServerInfo();
};

// implements the client role protocol.
class SrsRtmpClient
{
private:
    SrsHandshakeBytes* hs_bytes;
protected:
    SrsProtocol* protocol;
    ISrsProtocolReadWriter* io;
public:
    SrsRtmpClient(ISrsProtocolReadWriter* skt);
    virtual ~SrsRtmpClient();
// Protocol methods proxy
public:
    virtual void set_recv_timeout(srs_utime_t tm);
    virtual void set_send_timeout(srs_utime_t tm);
    virtual int64_t get_recv_bytes();
    virtual int64_t get_send_bytes();
    virtual srs_error_t recv_message(SrsCommonMessage** pmsg);
    virtual srs_error_t decode_message(SrsCommonMessage* msg, SrsPacket** ppacket);
    virtual srs_error_t send_and_free_message(SrsSharedPtrMessage* msg, int stream_id);
    virtual srs_error_t send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, int stream_id);
    virtual srs_error_t send_and_free_packet(SrsPacket* packet, int stream_id);
public:
    // handshake with server, try complex, then simple handshake.
    virtual srs_error_t handshake();
    // only use simple handshake
    virtual srs_error_t simple_handshake();
    // only use complex handshake
    virtual srs_error_t complex_handshake();
    // Connect to RTMP tcUrl and app, get the server info.
    //
    // @param app, The app to connect at, for example, live.
    // @param tcUrl, The tcUrl to connect at, for example, rtmp://ossrs.net/live.
    // @param req, the optional req object, use the swfUrl/pageUrl if specified. NULL to ignore.
    // @param dsu, Whether debug SRS upnode. For edge, set to true to send its info to upnode.
    // @param si, The server information, retrieve from response of connect app request. NULL to ignore.
    virtual srs_error_t connect_app(std::string app, std::string tcUrl, SrsRequest* r, bool dsu, SrsServerInfo* si);
    // Create a stream, then play/publish data over this stream.
    virtual srs_error_t create_stream(int& stream_id);
    // start play stream.
    virtual srs_error_t play(std::string stream, int stream_id, int chunk_size);
    // start publish stream. use flash publish workflow:
    //       connect-app => create-stream => flash-publish
    virtual srs_error_t publish(std::string stream, int stream_id, int chunk_size);
    // start publish stream. use FMLE publish workflow:
    //       connect-app => FMLE publish
    virtual srs_error_t fmle_publish(std::string stream, int& stream_id);
public:
    // Expect a specified message, drop others util got specified one.
    // @pmsg, user must free it. NULL if not success.
    // @ppacket, user must free it, which decode from payload of message. NULL if not success.
    // @remark, only when success, user can use and must free the pmsg and ppacket.
    // For example:
    //          SrsCommonMessage* msg = NULL;
    //          SrsConnectAppResPacket* pkt = NULL;
    //          if ((ret = client->expect_message<SrsConnectAppResPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) {
    //              return ret;
    //          }
    //          // Use then free msg and pkt
    //          srs_freep(msg);
    //          srs_freep(pkt);
    // user should never recv message and convert it, use this method instead.
    // if need to set timeout, use set timeout of SrsProtocol.
    template<class T>
    srs_error_t expect_message(SrsCommonMessage** pmsg, T** ppacket)
    {
        return protocol->expect_message<T>(pmsg, ppacket);
    }
};

// The rtmp provices rtmp-command-protocol services,
// a high level protocol, media stream oriented services,
// such as connect to vhost/app, play stream, get audio/video data.
class SrsRtmpServer
{
private:
    SrsHandshakeBytes* hs_bytes;
    SrsProtocol* protocol;
    ISrsProtocolReadWriter* io;
public:
    SrsRtmpServer(ISrsProtocolReadWriter* skt);
    virtual ~SrsRtmpServer();
public:
    // For RTMP proxy, the real IP. 0 if no proxy.
    // @doc https://github.com/ossrs/go-oryx/wiki/RtmpProxy
    virtual uint32_t proxy_real_ip();
// Protocol methods proxy
public:
    // Set the auto response message when recv for protocol stack.
    // @param v, whether auto response message when recv message.
    virtual void set_auto_response(bool v);
#ifdef SRS_PERF_MERGED_READ
    // To improve read performance, merge some packets then read,
    // When it on and read small bytes, we sleep to wait more data.,
    // that is, we merge some data to read together.
    // @param v true to ename merged read.
    // @param handler the handler when merge read is enabled.
    virtual void set_merge_read(bool v, IMergeReadHandler* handler);
    // Create buffer with specifeid size.
    // @param buffer the size of buffer.
    // @remark when MR(SRS_PERF_MERGED_READ) disabled, always set to 8K.
    // @remark when buffer changed, the previous ptr maybe invalid.
    virtual void set_recv_buffer(int buffer_size);
#endif
    // To set/get the recv timeout in srs_utime_t.
    // if timeout, recv/send message return ERROR_SOCKET_TIMEOUT.
    virtual void set_recv_timeout(srs_utime_t tm);
    virtual srs_utime_t get_recv_timeout();
    // To set/get the send timeout in srs_utime_t.
    // if timeout, recv/send message return ERROR_SOCKET_TIMEOUT.
    virtual void set_send_timeout(srs_utime_t tm);
    virtual srs_utime_t get_send_timeout();
    // Get recv/send bytes.
    virtual int64_t get_recv_bytes();
    virtual int64_t get_send_bytes();
    // Recv a RTMP message, which is bytes oriented.
    // user can use decode_message to get the decoded RTMP packet.
    // @param pmsg, set the received message,
    //       always NULL if error,
    //       NULL for unknown packet but return success.
    //       never NULL if decode success.
    // @remark, drop message when msg is empty or payload length is empty.
    virtual srs_error_t recv_message(SrsCommonMessage** pmsg);
    // Decode bytes oriented RTMP message to RTMP packet,
    // @param ppacket, output decoded packet,
    //       always NULL if error, never NULL if success.
    // @return error when unknown packet, error when decode failed.
    virtual srs_error_t decode_message(SrsCommonMessage* msg, SrsPacket** ppacket);
    // Send the RTMP message and always free it.
    // user must never free or use the msg after this method,
    // For it will always free the msg.
    // @param msg, the msg to send out, never be NULL.
    // @param stream_id, the stream id of packet to send over, 0 for control message.
    virtual srs_error_t send_and_free_message(SrsSharedPtrMessage* msg, int stream_id);
    // Send the RTMP message and always free it.
    // user must never free or use the msg after this method,
    // For it will always free the msg.
    // @param msgs, the msgs to send out, never be NULL.
    // @param nb_msgs, the size of msgs to send out.
    // @param stream_id, the stream id of packet to send over, 0 for control message.
    //
    // @remark performance issue, to support 6k+ 250kbps client,
    virtual srs_error_t send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, int stream_id);
    // Send the RTMP packet and always free it.
    // user must never free or use the packet after this method,
    // For it will always free the packet.
    // @param packet, the packet to send out, never be NULL.
    // @param stream_id, the stream id of packet to send over, 0 for control message.
    virtual srs_error_t send_and_free_packet(SrsPacket* packet, int stream_id);
public:
    // Do handshake with client, try complex then simple.
    virtual srs_error_t handshake();
    // Do connect app with client, to discovery tcUrl.
    virtual srs_error_t connect_app(SrsRequest* req);
    // Set output ack size to client, client will send ack-size for each ack window
    virtual srs_error_t set_window_ack_size(int ack_size);
    // Set the default input ack size value.
    virtual srs_error_t set_in_window_ack_size(int ack_size);
    // @type: The sender can mark this message hard (0), soft (1), or dynamic (2)
    // using the Limit type field.
    virtual srs_error_t set_peer_bandwidth(int bandwidth, int type);
    // @param server_ip the ip of server.
    virtual srs_error_t response_connect_app(SrsRequest* req, const char* server_ip = NULL);
    // Redirect the connection to another rtmp server.
    // @param a RTMP url to redirect to.
    // @param whether the client accept the redirect.
    virtual srs_error_t redirect(SrsRequest* r, std::string url, bool& accepted);
    // Reject the connect app request.
    virtual void response_connect_reject(SrsRequest* req, const char* desc);
    // Response  client the onBWDone message.
    virtual srs_error_t on_bw_done();
    // Recv some message to identify the client.
    // @stream_id, client will createStream to play or publish by flash,
    //         the stream_id used to response the createStream request.
    // @type, output the client type.
    // @stream_name, output the client publish/play stream name. @see: SrsRequest.stream
    // @duration, output the play client duration. @see: SrsRequest.duration
    virtual srs_error_t identify_client(int stream_id, SrsRtmpConnType& type, std::string& stream_name, srs_utime_t& duration);
    // Set the chunk size when client type identified.
    virtual srs_error_t set_chunk_size(int chunk_size);
    // When client type is play, response with packets:
    // StreamBegin,
    // onStatus(NetStream.Play.Reset), onStatus(NetStream.Play.Start).,
    // |RtmpSampleAccess(false, false),
    // onStatus(NetStream.Data.Start).
    virtual srs_error_t start_play(int stream_id);
    // When client(type is play) send pause message,
    // if is_pause, response the following packets:
    //     onStatus(NetStream.Pause.Notify)
    //     StreamEOF
    // if not is_pause, response the following packets:
    //     onStatus(NetStream.Unpause.Notify)
    //     StreamBegin
    virtual srs_error_t on_play_client_pause(int stream_id, bool is_pause);
    // When client type is publish, response with packets:
    // releaseStream response
    // FCPublish
    // FCPublish response
    // createStream response
    // onFCPublish(NetStream.Publish.Start)
    // onStatus(NetStream.Publish.Start)
    virtual srs_error_t start_fmle_publish(int stream_id);
    // For encoder of Haivision, response the startup request.
    // @see https://github.com/ossrs/srs/issues/844
    virtual srs_error_t start_haivision_publish(int stream_id);
    // process the FMLE unpublish event.
    // @unpublish_tid the unpublish request transaction id.
    virtual srs_error_t fmle_unpublish(int stream_id, double unpublish_tid);
    // When client type is publish, response with packets:
    // onStatus(NetStream.Publish.Start)
    virtual srs_error_t start_flash_publish(int stream_id);
public:
    // Expect a specified message, drop others util got specified one.
    // @pmsg, user must free it. NULL if not success.
    // @ppacket, user must free it, which decode from payload of message. NULL if not success.
    // @remark, only when success, user can use and must free the pmsg and ppacket.
    // For example:
    //          SrsCommonMessage* msg = NULL;
    //          SrsConnectAppResPacket* pkt = NULL;
    //          if ((ret = server->expect_message<SrsConnectAppResPacket>(&msg, &pkt)) != ERROR_SUCCESS) {
    //              return ret;
    //          }
    //          // Use then free msg and pkt
    //          srs_freep(msg);
    //          srs_freep(pkt);
    // user should never recv message and convert it, use this method instead.
    // if need to set timeout, use set timeout of SrsProtocol.
    template<class T>
    srs_error_t expect_message(SrsCommonMessage** pmsg, T** ppacket)
    {
        return protocol->expect_message<T>(pmsg, ppacket);
    }
private:
    virtual srs_error_t identify_create_stream_client(SrsCreateStreamPacket* req, int stream_id, int depth, SrsRtmpConnType& type, std::string& stream_name, srs_utime_t& duration);
    virtual srs_error_t identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsRtmpConnType& type, std::string& stream_name);
    virtual srs_error_t identify_haivision_publish_client(SrsFMLEStartPacket* req, SrsRtmpConnType& type, std::string& stream_name);
    virtual srs_error_t identify_flash_publish_client(SrsPublishPacket* req, SrsRtmpConnType& type, std::string& stream_name);
private:
    virtual srs_error_t identify_play_client(SrsPlayPacket* req, SrsRtmpConnType& type, std::string& stream_name, srs_utime_t& duration);
};

// 4.1.1. connect
// The client sends the connect command to the server to request
// connection to a server application instance.
class SrsConnectAppPacket : public SrsPacket
{
public:
    // Name of the command. Set to "connect".
    std::string command_name;
    // Always set to 1.
    double transaction_id;
    // Command information object which has the name-value pairs.
    // @remark: alloc in packet constructor, user can directly use it,
    //       user should never alloc it again which will cause memory leak.
    // @remark, never be NULL.
    SrsAmf0Object* command_object;
    // Any optional information
    // @remark, optional, init to and maybe NULL.
    SrsAmf0Object* args;
public:
    SrsConnectAppPacket();
    virtual ~SrsConnectAppPacket();
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};
// Response  for SrsConnectAppPacket.
class SrsConnectAppResPacket : public SrsPacket
{
public:
    // The _result or _error; indicates whether the response is result or error.
    std::string command_name;
    // Transaction ID is 1 for call connect responses
    double transaction_id;
    // Name-value pairs that describe the properties(fmsver etc.) of the connection.
    // @remark, never be NULL.
    SrsAmf0Object* props;
    // Name-value pairs that describe the response from|the server. 'code',
    // 'level', 'description' are names of few among such information.
    // @remark, never be NULL.
    SrsAmf0Object* info;
public:
    SrsConnectAppResPacket();
    virtual ~SrsConnectAppResPacket();
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// 4.1.2. Call
// The call method of the NetConnection object runs remote procedure
// calls (RPC) at the receiving end. The called RPC name is passed as a
// parameter to the call command.
class SrsCallPacket : public SrsPacket
{
public:
    // Name of the remote procedure that is called.
    std::string command_name;
    // If a response is expected we give a transaction Id. Else we pass a value of 0
    double transaction_id;
    // If there exists any command info this
    // is set, else this is set to null type.
    // @remark, optional, init to and maybe NULL.
    SrsAmf0Any* command_object;
    // Any optional arguments to be provided
    // @remark, optional, init to and maybe NULL.
    SrsAmf0Any* arguments;
public:
    SrsCallPacket();
    virtual ~SrsCallPacket();
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};
// Response  for SrsCallPacket.
class SrsCallResPacket : public SrsPacket
{
public:
    // Name of the command.
    std::string command_name;
    // ID of the command, to which the response belongs to
    double transaction_id;
    // If there exists any command info this is set, else this is set to null type.
    // @remark, optional, init to and maybe NULL.
    SrsAmf0Any* command_object;
    // Response from the method that was called.
    // @remark, optional, init to and maybe NULL.
    SrsAmf0Any* response;
public:
    SrsCallResPacket(double _transaction_id);
    virtual ~SrsCallResPacket();
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// 4.1.3. createStream
// The client sends this command to the server to create a logical
// channel for message communication The publishing of audio, video, and
// metadata is carried out over stream channel created using the
// createStream command.
class SrsCreateStreamPacket : public SrsPacket
{
public:
    // Name of the command. Set to "createStream".
    std::string command_name;
    // Transaction ID of the command.
    double transaction_id;
    // If there exists any command info this is set, else this is set to null type.
    // @remark, never be NULL, an AMF0 null instance.
    SrsAmf0Any* command_object; // null
public:
    SrsCreateStreamPacket();
    virtual ~SrsCreateStreamPacket();
public:
    void set_command_object(SrsAmf0Any* v);
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};
// Response  for SrsCreateStreamPacket.
class SrsCreateStreamResPacket : public SrsPacket
{
public:
    // The _result or _error; indicates whether the response is result or error.
    std::string command_name;
    // ID of the command that response belongs to.
    double transaction_id;
    // If there exists any command info this is set, else this is set to null type.
    // @remark, never be NULL, an AMF0 null instance.
    SrsAmf0Any* command_object; // null
    // The return value is either a stream ID or an error information object.
    double stream_id;
public:
    SrsCreateStreamResPacket(double _transaction_id, double _stream_id);
    virtual ~SrsCreateStreamResPacket();
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// client close stream packet.
class SrsCloseStreamPacket : public SrsPacket
{
public:
    // Name of the command, set to "closeStream".
    std::string command_name;
    // Transaction ID set to 0.
    double transaction_id;
    // Command information object does not exist. Set to null type.
    // @remark, never be NULL, an AMF0 null instance.
    SrsAmf0Any* command_object; // null
public:
    SrsCloseStreamPacket();
    virtual ~SrsCloseStreamPacket();
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
};

// FMLE start publish: ReleaseStream/PublishStream/FCPublish/FCUnpublish
class SrsFMLEStartPacket : public SrsPacket
{
public:
    // Name of the command
    std::string command_name;
    // The transaction ID to get the response.
    double transaction_id;
    // If there exists any command info this is set, else this is set to null type.
    // @remark, never be NULL, an AMF0 null instance.
    SrsAmf0Any* command_object; // null
    // The stream name to start publish or release.
    std::string stream_name;
public:
    SrsFMLEStartPacket();
    virtual ~SrsFMLEStartPacket();
public:
    void set_command_object(SrsAmf0Any* v);
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
// Factory method to create specified FMLE packet.
public:
    static SrsFMLEStartPacket* create_release_stream(std::string stream);
    static SrsFMLEStartPacket* create_FC_publish(std::string stream);
};
// Response  for SrsFMLEStartPacket.
class SrsFMLEStartResPacket : public SrsPacket
{
public:
    // Name of the command
    std::string command_name;
    // The transaction ID to get the response.
    double transaction_id;
    // If there exists any command info this is set, else this is set to null type.
    // @remark, never be NULL, an AMF0 null instance.
    SrsAmf0Any* command_object; // null
    // The optional args, set to undefined.
    // @remark, never be NULL, an AMF0 undefined instance.
    SrsAmf0Any* args; // undefined
public:
    SrsFMLEStartResPacket(double _transaction_id);
    virtual ~SrsFMLEStartResPacket();
public:
    void set_args(SrsAmf0Any* v);
    void set_command_object(SrsAmf0Any* v);
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// FMLE/flash publish
// 4.2.6. Publish
// The client sends the publish command to publish a named stream to the
// server. Using this name, any client can play this stream and receive
// The published audio, video, and data messages.
class SrsPublishPacket : public SrsPacket
{
public:
    // Name of the command, set to "publish".
    std::string command_name;
    // Transaction ID set to 0.
    double transaction_id;
    // Command information object does not exist. Set to null type.
    // @remark, never be NULL, an AMF0 null instance.
    SrsAmf0Any* command_object; // null
    // Name with which the stream is published.
    std::string stream_name;
    // Type of publishing. Set to "live", "record", or "append".
    //   record: The stream is published and the data is recorded to a new file.The file
    //           is stored on the server in a subdirectory within the directory that
    //           contains the server application. If the file already exists, it is
    //           overwritten.
    //   append: The stream is published and the data is appended to a file. If no file
    //           is found, it is created.
    //   live: Live data is published without recording it in a file.
    // @remark, SRS only support live.
    // @remark, optional, default to live.
    std::string type;
public:
    SrsPublishPacket();
    virtual ~SrsPublishPacket();
public:
    void set_command_object(SrsAmf0Any* v);
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// 4.2.8. pause
// The client sends the pause command to tell the server to pause or
// start playing.
class SrsPausePacket : public SrsPacket
{
public:
    // Name of the command, set to "pause".
    std::string command_name;
    // There is no transaction ID for this command. Set to 0.
    double transaction_id;
    // Command information object does not exist. Set to null type.
    // @remark, never be NULL, an AMF0 null instance.
    SrsAmf0Any* command_object; // null
    // true or false, to indicate pausing or resuming play
    bool is_pause;
    // Number of milliseconds at which the the stream is paused or play resumed.
    // This is the current stream time at the Client when stream was paused. When the
    // playback is resumed, the server will only send messages with timestamps
    // greater than this value.
    double time_ms;
public:
    SrsPausePacket();
    virtual ~SrsPausePacket();
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
};

// 4.2.1. play
// The client sends this command to the server to play a stream.
class SrsPlayPacket : public SrsPacket
{
public:
    // Name of the command. Set to "play".
    std::string command_name;
    // Transaction ID set to 0.
    double transaction_id;
    // Command information does not exist. Set to null type.
    // @remark, never be NULL, an AMF0 null instance.
    SrsAmf0Any* command_object; // null
    // Name of the stream to play.
    // To play video (FLV) files, specify the name of the stream without a file
    //       extension (for example, "sample").
    // To play back MP3 or ID3 tags, you must precede the stream name with mp3:
    //       (for example, "mp3:sample".)
    // To play H.264/AAC files, you must precede the stream name with mp4: and specify the
    //       file extension. For example, to play the file sample.m4v, specify
    //       "mp4:sample.m4v"
    std::string stream_name;
    // An optional parameter that specifies the start time in seconds.
    // The default value is -2, which means the subscriber first tries to play the live
    //       stream specified in the Stream Name field. If a live stream of that name is
    //       not found, it plays the recorded stream specified in the Stream Name field.
    // If you pass -1 in the Start field, only the live stream specified in the Stream
    //       Name field is played.
    // If you pass 0 or a positive number in the Start field, a recorded stream specified
    //       in the Stream Name field is played beginning from the time specified in the
    //       Start field.
    // If no recorded stream is found, the next item in the playlist is played.
    double start;
    // An optional parameter that specifies the duration of playback in seconds.
    // The default value is -1. The -1 value means a live stream is played until it is no
    //       longer available or a recorded stream is played until it ends.
    // If u pass 0, it plays the single frame since the time specified in the Start field
    //       from the beginning of a recorded stream. It is assumed that the value specified
    //       in the Start field is equal to or greater than 0.
    // If you pass a positive number, it plays a live stream for the time period specified
    //       in the Duration field. After that it becomes available or plays a recorded
    //       stream for the time specified in the Duration field. (If a stream ends before the
    //       time specified in the Duration field, playback ends when the stream ends.)
    // If you pass a negative number other than -1 in the Duration field, it interprets the
    //       value as if it were -1.
    double duration;
    // An optional Boolean value or number that specifies whether to flush any
    // previous playlist.
    bool reset;
public:
    SrsPlayPacket();
    virtual ~SrsPlayPacket();
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// Response  for SrsPlayPacket.
// @remark, user must set the stream_id in header.
class SrsPlayResPacket : public SrsPacket
{
public:
    // Name of the command. If the play command is successful, the command
    // name is set to onStatus.
    std::string command_name;
    // Transaction ID set to 0.
    double transaction_id;
    // Command information does not exist. Set to null type.
    // @remark, never be NULL, an AMF0 null instance.
    SrsAmf0Any* command_object; // null
    // If the play command is successful, the client receives OnStatus message from
    // server which is NetStream.Play.Start. If the specified stream is not found,
    // NetStream.Play.StreamNotFound is received.
    // @remark, never be NULL, an AMF0 object instance.
    SrsAmf0Object* desc;
public:
    SrsPlayResPacket();
    virtual ~SrsPlayResPacket();
public:
    void set_command_object(SrsAmf0Any* v);
    void set_desc(SrsAmf0Object* v);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// When bandwidth test done, notice client.
class SrsOnBWDonePacket : public SrsPacket
{
public:
    // Name of command. Set to "onBWDone"
    std::string command_name;
    // Transaction ID set to 0.
    double transaction_id;
    // Command information does not exist. Set to null type.
    // @remark, never be NULL, an AMF0 null instance.
    SrsAmf0Any* args; // null
public:
    SrsOnBWDonePacket();
    virtual ~SrsOnBWDonePacket();
public:
    void set_args(SrsAmf0Any* v);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// onStatus command, AMF0 Call
// @remark, user must set the stream_id by SrsCommonMessage.set_packet().
class SrsOnStatusCallPacket : public SrsPacket
{
public:
    // Name of command. Set to "onStatus"
    std::string command_name;
    // Transaction ID set to 0.
    double transaction_id;
    // Command information does not exist. Set to null type.
    // @remark, never be NULL, an AMF0 null instance.
    SrsAmf0Any* args; // null
    // Name-value pairs that describe the response from the server.
    // 'code','level', 'description' are names of few among such information.
    // @remark, never be NULL, an AMF0 object instance.
    SrsAmf0Object* data;
public:
    SrsOnStatusCallPacket();
    virtual ~SrsOnStatusCallPacket();
public:
    void set_args(SrsAmf0Any* v);
    void set_data(SrsAmf0Object* v);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// onStatus data, AMF0 Data
// @remark, user must set the stream_id by SrsCommonMessage.set_packet().
class SrsOnStatusDataPacket : public SrsPacket
{
public:
    // Name of command. Set to "onStatus"
    std::string command_name;
    // Name-value pairs that describe the response from the server.
    // 'code', are names of few among such information.
    // @remark, never be NULL, an AMF0 object instance.
    SrsAmf0Object* data;
public:
    SrsOnStatusDataPacket();
    virtual ~SrsOnStatusDataPacket();
public:
    void set_data(SrsAmf0Object* v);
    SrsAmf0Object* get_data();
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// AMF0Data RtmpSampleAccess
// @remark, user must set the stream_id by SrsCommonMessage.set_packet().
class SrsSampleAccessPacket : public SrsPacket
{
public:
    // Name of command. Set to "|RtmpSampleAccess".
    std::string command_name;
    // Whether allow access the sample of video.
    // @see: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#videoSampleAccess
    bool video_sample_access;
    // Whether allow access the sample of audio.
    // @see: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#audioSampleAccess
    bool audio_sample_access;
public:
    SrsSampleAccessPacket();
    virtual ~SrsSampleAccessPacket();
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// The stream metadata.
// FMLE: @setDataFrame
// others: onMetaData
class SrsOnMetaDataPacket : public SrsPacket
{
public:
    // Name of metadata. Set to "onMetaData"
    std::string name;
    // Metadata of stream.
    // @remark, never be NULL, an AMF0 object instance.
    SrsAmf0Object* metadata;
public:
    SrsOnMetaDataPacket();
    virtual ~SrsOnMetaDataPacket();
public:
    void set_metadata(SrsAmf0Object* v);
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// 5.5. Window Acknowledgement Size (5)
// The client or the server sends this message to inform the peer which
// window size to use when sending acknowledgment.
class SrsSetWindowAckSizePacket : public SrsPacket
{
public:
    int32_t ackowledgement_window_size;
public:
    SrsSetWindowAckSizePacket();
    virtual ~SrsSetWindowAckSizePacket();
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// 5.3. Acknowledgement (3)
// The client or the server sends the acknowledgment to the peer after
// receiving bytes equal to the window size.
class SrsAcknowledgementPacket : public SrsPacket
{
public:
    uint32_t sequence_number;
public:
    SrsAcknowledgementPacket();
    virtual ~SrsAcknowledgementPacket();
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// 7.1. Set Chunk Size
// Protocol control message 1, Set Chunk Size, is used to notify the
// peer about the new maximum chunk size.
class SrsSetChunkSizePacket : public SrsPacket
{
public:
    // The maximum chunk size can be 65536 bytes. The chunk size is
    // maintained independently for each direction.
    int32_t chunk_size;
public:
    SrsSetChunkSizePacket();
    virtual ~SrsSetChunkSizePacket();
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// 5.6. Set Peer Bandwidth (6)
enum SrsPeerBandwidthType
{
    // The sender can mark this message hard (0), soft (1), or dynamic (2)
    // using the Limit type field.
    SrsPeerBandwidthHard = 0,
    SrsPeerBandwidthSoft = 1,
    SrsPeerBandwidthDynamic = 2,
};

// 5.6. Set Peer Bandwidth (6)
// The client or the server sends this message to update the output
// bandwidth of the peer.
class SrsSetPeerBandwidthPacket : public SrsPacket
{
public:
    int32_t bandwidth;
    // @see: SrsPeerBandwidthType
    int8_t type;
public:
    SrsSetPeerBandwidthPacket();
    virtual ~SrsSetPeerBandwidthPacket();
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

// 3.7. User Control message
enum SrcPCUCEventType
{
    // Generally, 4bytes event-data

    // The server sends this event to notify the client
    // that a stream has become functional and can be
    // used for communication. By default, this event
    // is sent on ID 0 after the application connect
    // command is successfully received from the
    // client. The event data is 4-byte and represents
    // The stream ID of the stream that became
    // Functional.
    SrcPCUCStreamBegin = 0x00,

    // The server sends this event to notify the client
    // that the playback of data is over as requested
    // on this stream. No more data is sent without
    // issuing additional commands. The client discards
    // The messages received for the stream. The
    // 4 bytes of event data represent the ID of the
    // stream on which playback has ended.
    SrcPCUCStreamEOF = 0x01,

    // The server sends this event to notify the client
    // that there is no more data on the stream. If the
    // server does not detect any message for a time
    // period, it can notify the subscribed clients
    // that the stream is dry. The 4 bytes of event
    // data represent the stream ID of the dry stream.
    SrcPCUCStreamDry = 0x02,

    // The client sends this event to inform the server
    // of the buffer size (in milliseconds) that is
    // used to buffer any data coming over a stream.
    // This event is sent before the server starts
    // processing the stream. The first 4 bytes of the
    // event data represent the stream ID and the next
    // 4 bytes represent the buffer length, in
    // milliseconds.
    SrcPCUCSetBufferLength = 0x03, // 8bytes event-data

    // The server sends this event to notify the client
    // that the stream is a recorded stream. The
    // 4 bytes event data represent the stream ID of
    // The recorded stream.
    SrcPCUCStreamIsRecorded = 0x04,

    // The server sends this event to test whether the
    // client is reachable. Event data is a 4-byte
    // timestamp, representing the local server time
    // When the server dispatched the command. The
    // client responds with kMsgPingResponse on
    // receiving kMsgPingRequest.
    SrcPCUCPingRequest = 0x06,

    // The client sends this event to the server in
    // Response  to the ping request. The event data is
    // a 4-byte timestamp, which was received with the
    // kMsgPingRequest request.
    SrcPCUCPingResponse = 0x07,

    // For PCUC size=3, for example the payload is "00 1A 01",
    // it's a FMS control event, where the event type is 0x001a and event data is 0x01,
    // please notice that the event data is only 1 byte for this event.
    SrsPCUCFmsEvent0 = 0x1a,
};

// 5.4. User Control Message (4)
//
// For the EventData is 4bytes.
// Stream Begin(=0)              4-bytes stream ID
// Stream EOF(=1)                4-bytes stream ID
// StreamDry(=2)                 4-bytes stream ID
// SetBufferLength(=3)           8-bytes 4bytes stream ID, 4bytes buffer length.
// StreamIsRecorded(=4)          4-bytes stream ID
// PingRequest(=6)               4-bytes timestamp local server time
// PingResponse(=7)              4-bytes timestamp received ping request.
//
// 3.7. User Control message
// +------------------------------+-------------------------
// | Event Type ( 2- bytes ) | Event Data
// +------------------------------+-------------------------
// Figure 5 Pay load for the 'User Control Message'.
class SrsUserControlPacket : public SrsPacket
{
public:
    // Event type is followed by Event data.
    // @see: SrcPCUCEventType
    int16_t event_type;
    // The event data generally in 4bytes.
    // @remark for event type is 0x001a, only 1bytes.
    // @see SrsPCUCFmsEvent0
    int32_t event_data;
    // 4bytes if event_type is SetBufferLength; otherwise 0.
    int32_t extra_data;
public:
    SrsUserControlPacket();
    virtual ~SrsUserControlPacket();
// Decode functions for concrete packet to override.
public:
    virtual srs_error_t decode(SrsBuffer* stream);
// Encode functions for concrete packet to override.
public:
    virtual int get_prefer_cid();
    virtual int get_message_type();
protected:
    virtual int get_size();
    virtual srs_error_t encode_packet(SrsBuffer* stream);
};

#endif


text:
Express Library Guide
=====================

Express-Stormpath is an extension for `Express`_ that makes it *incredibly*
simple to add users and user data to your application.  It aims to completely
abstract away all user registration, login, authentication, and authorization
problems, and make building secure websites painless.  And the best part?  **You
don't even need a database!**

This documentation will show you how to get started with Express-Stormpath.  If
you're a new Express-Stormpath user, start here!

.. toctree::
   :maxdepth: 2

   introduction
   setup
   configuration
   user_data
   authentication
   authorization
   registration
   login
   social_login
   logout
   password_reset
   multi_tenancy
   templates
   help
   contributors

Additional Notes
----------------

This part of the documentation covers changes between versions and upgrade
information, to help you migrate to newer versions of Express-Stormpath easily.

Express-Stormpath is made available under the `Apache License, Version 2.0`_.
In short, you can do pretty much whatever you want!

.. toctree::
   :maxdepth: 2

   changelog
   upgrading

.. _Express: http://expressjs.com/
.. _Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0.html


text:
namespace ZEUS {
    namespace Display {

        class ICanvas : public Scene::ISceneComponent {
        protected:
            Math::Color backgroundColor;
        public:
            ICanvas(Scene::SceneObject& p, ZeusID id)
                : ISceneComponent(p, id), backgroundColor(Math::Color(0.0f, 0.0f, 0.2f, 0.0f)) {}
            virtual Math::Vector<3, float> GetViewingDirection() const = 0;

            virtual Math::Matrix<4,4,float> GetProjectionMatrix() const = 0;

            inline Math::Color& BackgroundColor() { return backgroundColor;}
            inline const Math::Color& BackgroundColor() const { return backgroundColor;}
            //virtual void IsVisible(Box& b) = 0;
        };

    }
}

#endif