검색 결과


    이 문서는 기술적인 검토가 필요합니다.

    아직 자원 봉사자들이 한국어로 현재 문서를 번역하지 않았습니다. 가입해서 이 문서가 번역되는 일에 함께 해 주세요!

    « Gecko Plugin API Reference « Browser Side Plug-in API


    Pushes data into a stream produced by the plug-in and consumed by the browser.


    #include <npapi.h>
    int32 NPN_Write(NPP instance, 
              NPStream* stream,
              int32     len,
              void*     buf);


    The function has the following parameters:

    Pointer to the current plug-in instance.
    Pointer to the stream into which to push the data.
    Length in bytes of the data specified by buf.
    A pointer to a buffer of data to deliver to the stream.


    • If successful, the function returns a positive integer representing the number of bytes written (consumed by the browser). This number depends on the size of the browser's memory buffers, the number of active streams, and other factors.
    • If unsuccessful, the plug-in returns a negative integer. This indicates that the browser encountered an error while processing the data, so the plug-in should terminate the stream by calling NPN_DestroyStream().


    NPN_Write() delivers a buffer from the stream to the instance. A plug-in can call this function multiple times after creating a stream with NPN_NewStream(). The browser makes a copy of the buffer if necessary, so the plug-in can free the buffer as the method returns, if desired. See "Example of Sending a Stream" for an example that includes NPN_Write().


    This example pushes a snippet of HTML over a newly created stream, then destroys the stream when it's done.

    Note: You should actually handle errors, which this example doesn't do.
    NPStream* stream;
    char* myData = "<HTML><B>This is a message from my plug-in!</B></HTML>";
    int32 myLength = strlen(myData) + 1; 

    /* Create the stream. */

    err = NPN_NewStream(instance, "text/html", "_blank", &stream)

    /* Push data into the stream. */

    err = NPN_Write(instance, stream, myLength, myData);

    /* Delete the stream. */

    err = NPN_DestroyStream(instance, stream, NPRES_DONE);

    See also

    문서 태그 및 공헌자

    Contributors to this page: Sheppy, Pmash, Rickwookie, kscarfone
    최종 변경: kscarfone,