GithubHelp home page GithubHelp logo

p2p-signal-controller's Introduction

P2P-Dispatch-Framework(信令服务器)

P2P分发框架-信令服务器,用于控制连接,提供peer端寻找、控制信号转发等功能

端口占用:

    8080:   查看资源情况
    10000:  提供websocket服务

一、信令服务器接口

  • 3001 操作索引

    • 参数

        {
            code:   3001,
            data:[
                {
                    url:    "//www.example.com/example",    //资源:url绝对路径(如果客户端没有指定传输协议,则采用通用协议)
                    md5:    "34dfsf3afeefefefe"             //资源:md5校验代码
                },
                ...
            ]
        }
      
    • 返回结果

      • 1001 通知客户端MD5错误,需要丢弃的资源

          {
              code:   1001,
              data:[
                  "//www.example.com/example",            //资源:url绝对路径(如果客户端没有指定传输协议,则采用通用协议)
                  ...
              ]
          }
        
  • 3002 寻找有这些资源的客户端

    • 参数

        {
            code:   3002,
            data:[
                "//www.example.com/example",                //资源:url绝对路径(如果客户端没有指定传输协议,则采用通用协议)
                "http://www.example.com/example",
                "https://www.example.com/example",
                ...
            ]
        }
      
    • 返回结果

      • 1002 通知客户端每个的资源的第三方提供者 & 无第三方提供者的资源

          {
              code:       1002,
              data:{
                   //建议的资源提供者,相同资源按照顺序提供
                  reqs:               [{url, clients: [address, ...], }, ...],
                  //没有提供者的资源
                  notFindResources:   [url, ...]
              }
          }
        
  • 3003 转发描述(提供者)

    • 参数

        {
            code:   3003,
            data:   {
                offer:  {
                    //时间戳
                    timestamp:  number
                    //资源描述
                    desc:       object,
                    //IP地址
                    address:    string
                },
                answer: {
                    //时间戳
                    timestamp:  number,
                    //IP地址
                    address:    string
                }
            }
        }
      
    • 返回结果

        {
            code:   1003,
            //转发客户端data字段
            data:   object
        }
      
  • 3004 转发描述(响应者)

    • 参数

        {
            code:   3004,
            data:   {
                offer:  {
                    //时间戳
                    timestamp:  number
                    //资源描述
                    desc:       object,
                    //IP地址
                    address:    string
                },
                answer: {
                    //时间戳
                    timestamp:  number
                    //资源描述
                    desc:       object,
                    //IP地址
                    address:    string
                }
            }
        }
      
    • 返回结果

        {
            code:   1004,
            //转发客户端data字段
            data:   object
        }
      
  • 3005 转发候选信息

    • 特殊说明

        会出现2中情况:提供者-发送候选信息 & 响应者-发送候选信息;返回结果只是单纯转发,不做处理
      
    • 参数一(提供者)

        {
            code:   3005,
            data:   {
                offer:  {
                    //时间戳
                    timestamp:  number,
                    //资源描述
                    desc:       object,
                    //候选信息
                    candidate:  object
                },
                answer: {
                    //资源描述
                    desc:       object,
                    //IP地址
                    address:    string
                }
            }
        }
      
    • 参数二(响应者)

        {
            code:   3005,
            data:   {
                offer:  {
                    //资源描述
                    desc:       object,
                    //IP地址
                    address:    string
                },
                answer: {
                    //时间戳
                    timestamp:  number,
                    //资源描述
                    desc:       object,
                    //候选信息
                    candidate:  object
                }
            }
        }
      
    • 返回结果

        {
            code:   1005,
            //转发客户端data字段
            data:   object
        }
      
  • 3201 转发数据索取请求

    • 参数

        {
            code:   3201,
            data:   {
                url:    string,                 //请求的数据
                offer:  {
                    //IP地址
                    address:    string
                },
                answer: {
                    //时间戳
                    timestamp:  number
                }
            }
        }
      
    • 返回结果(增加响应者的IP地址)

        {
            code:   1201,
            data:   {
                offer:  {
                    //IP地址
                    address:    string
                },
                answer: {
                    //时间戳
                    timestamp:  number,
                    //IP地址(新增)
                    address:    string
                }
            }
        }
      
  • 3202 转发拒绝服务

    • 参数

        {
            code:   3202,
            data:   {
                offer:  {
                    //IP地址
                    address:    string
                    //可用
                    isAvailable: false
                },
                answer: {
                    //时间戳
                    timestamp:  number,
                    //IP地址
                    address:    string
                }
            }
        }
      
    • 返回结果

        {
            code:   1202,
            //转发客户端data字段
            data:   object
        }
      
  • 3203 转发终止请求

    • 参数(部分参数)

        {
            code:   3203,
            data:   {
                offer:{
                    //IP地址
                    address:    string,
      
                    ...                     //其它字段省略
                },
                answer: {
                    //时间戳
                    timestamp:  number,
                    //IP地址
                    address:    string
                    //是否可用
                    isAvailable: false
                }
            }
        }
      
    • 返回结果

        {
            code:   1203,
            //转发客户端data字段
            data:   object
        }
      
  • 3204 追加资源

    • 参数

            {
                code:   3204,
                data:   { url, md5 }
            }
      

二、客户端处理报文

    1001 丢弃资源
    1002 收到可用的客户端
    1003 收到请求描述信息
    1004 收到响应描述
    1005 收到候选信息
    1201 接收到发送数据请求,准备发送数据

p2p-signal-controller's People

Watchers

James Cloos avatar Michael avatar

Forkers

liheng2016

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.