Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

结合rtc接口 #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.cache
Binary file added packages/System.Net.Http.4.3.4/.signature.p7s
Binary file not shown.
Binary file not shown.
31 changes: 31 additions & 0 deletions packages/System.Net.Http.4.3.4/ThirdPartyNotices.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
This Microsoft .NET Library may incorporate components from the projects listed
below. Microsoft licenses these components under the Microsoft .NET Library
software license terms. The original copyright notices and the licenses under
which Microsoft received such components are set forth below for informational
purposes only. Microsoft reserves all rights not expressly granted herein,
whether by implication, estoppel or otherwise.

1. .NET Core (https://github.com/dotnet/core/)

.NET Core
Copyright (c) .NET Foundation and Contributors

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
128 changes: 128 additions & 0 deletions packages/System.Net.Http.4.3.4/dotnet_library_license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@

MICROSOFT SOFTWARE LICENSE TERMS


MICROSOFT .NET LIBRARY

These license terms are an agreement between Microsoft Corporation (or based on where you live, one of its affiliates) and you. Please read them. They apply to the software named above, which includes the media on which you received it, if any. The terms also apply to any Microsoft

· updates,

· supplements,

· Internet-based services, and

· support services

for this software, unless other terms accompany those items. If so, those terms apply.

BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS. IF YOU DO NOT ACCEPT THEM, DO NOT USE THE SOFTWARE.


IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE PERPETUAL RIGHTS BELOW.

1. INSTALLATION AND USE RIGHTS.

a. Installation and Use. You may install and use any number of copies of the software to design, develop and test your programs.

b. Third Party Programs. The software may include third party programs that Microsoft, not the third party, licenses to you under this agreement. Notices, if any, for the third party program are included for your information only.

2. ADDITIONAL LICENSING REQUIREMENTS AND/OR USE RIGHTS.

a. DISTRIBUTABLE CODE. The software is comprised of Distributable Code. “Distributable Code” is code that you are permitted to distribute in programs you develop if you comply with the terms below.

i. Right to Use and Distribute.

· You may copy and distribute the object code form of the software.

· Third Party Distribution. You may permit distributors of your programs to copy and distribute the Distributable Code as part of those programs.

ii. Distribution Requirements. For any Distributable Code you distribute, you must

· add significant primary functionality to it in your programs;

· require distributors and external end users to agree to terms that protect it at least as much as this agreement;

· display your valid copyright notice on your programs; and

· indemnify, defend, and hold harmless Microsoft from any claims, including attorneys’ fees, related to the distribution or use of your programs.

iii. Distribution Restrictions. You may not

· alter any copyright, trademark or patent notice in the Distributable Code;

· use Microsoft’s trademarks in your programs’ names or in a way that suggests your programs come from or are endorsed by Microsoft;

· include Distributable Code in malicious, deceptive or unlawful programs; or

· modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An Excluded License is one that requires, as a condition of use, modification or distribution, that

· the code be disclosed or distributed in source code form; or

· others have the right to modify it.

3. SCOPE OF LICENSE. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the software only as expressly permitted in this agreement. In doing so, you must comply with any technical limitations in the software that only allow you to use it in certain ways. You may not

· work around any technical limitations in the software;

· reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;

· publish the software for others to copy;

· rent, lease or lend the software;

· transfer the software or this agreement to any third party; or

· use the software for commercial software hosting services.

4. BACKUP COPY. You may make one backup copy of the software. You may use it only to reinstall the software.

5. DOCUMENTATION. Any person that has valid access to your computer or internal network may copy and use the documentation for your internal, reference purposes.

6. EXPORT RESTRICTIONS. The software is subject to United States export laws and regulations. You must comply with all domestic and international export laws and regulations that apply to the software. These laws include restrictions on destinations, end users and end use. For additional information, see www.microsoft.com/exporting.

7. SUPPORT SERVICES. Because this software is “as is,” we may not provide support services for it.

8. ENTIRE AGREEMENT. This agreement, and the terms for supplements, updates, Internet-based services and support services that you use, are the entire agreement for the software and support services.

9. APPLICABLE LAW.

a. United States. If you acquired the software in the United States, Washington state law governs the interpretation of this agreement and applies to claims for breach of it, regardless of conflict of laws principles. The laws of the state where you live govern all other claims, including claims under state consumer protection laws, unfair competition laws, and in tort.

b. Outside the United States. If you acquired the software in any other country, the laws of that country apply.

10. LEGAL EFFECT. This agreement describes certain legal rights. You may have other rights under the laws of your country. You may also have rights with respect to the party from whom you acquired the software. This agreement does not change your rights under the laws of your country if the laws of your country do not permit it to do so.

11. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED “AS-IS.” YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES OR CONDITIONS. YOU MAY HAVE ADDITIONAL CONSUMER RIGHTS OR STATUTORY GUARANTEES UNDER YOUR LOCAL LAWS WHICH THIS AGREEMENT CANNOT CHANGE. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.

FOR AUSTRALIA – YOU HAVE STATUTORY GUARANTEES UNDER THE AUSTRALIAN CONSUMER LAW AND NOTHING IN THESE TERMS IS INTENDED TO AFFECT THOSE RIGHTS.

12. LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES.

This limitation applies to

· anything related to the software, services, content (including code) on third party Internet sites, or third party programs; and

· claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law.

It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your country may not allow the exclusion or limitation of incidental, consequential or other damages.

Please note: As this software is distributed in Quebec, Canada, some of the clauses in this agreement are provided below in French.

Remarque : Ce logiciel étant distribué au Québec, Canada, certaines des clauses dans ce contrat sont fournies ci-dessous en français.

EXONÉRATION DE GARANTIE. Le logiciel visé par une licence est offert « tel quel ». Toute utilisation de ce logiciel est à votre seule risque et péril. Microsoft n’accorde aucune autre garantie expresse. Vous pouvez bénéficier de droits additionnels en vertu du droit local sur la protection des consommateurs, que ce contrat ne peut modifier. La ou elles sont permises par le droit locale, les garanties implicites de qualité marchande, d’adéquation à un usage particulier et d’absence de contrefaçon sont exclues.

LIMITATION DES DOMMAGES-INTÉRÊTS ET EXCLUSION DE RESPONSABILITÉ POUR LES DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement à hauteur de 5,00 $ US. Vous ne pouvez prétendre à aucune indemnisation pour les autres dommages, y compris les dommages spéciaux, indirects ou accessoires et pertes de bénéfices.

Cette limitation concerne :

· tout ce qui est relié au logiciel, aux services ou au contenu (y compris le code) figurant sur des sites Internet tiers ou dans des programmes tiers ; et

· les réclamations au titre de violation de contrat ou de garantie, ou au titre de responsabilité stricte, de négligence ou d’une autre faute dans la limite autorisée par la loi en vigueur.

Elle s’applique également, même si Microsoft connaissait ou devrait connaître l’éventualité d’un tel dommage. Si votre pays n’autorise pas l’exclusion ou la limitation de responsabilité pour les dommages indirects, accessoires ou de quelque nature que ce soit, il se peut que la limitation ou l’exclusion ci-dessus ne s’appliquera pas à votre égard.

EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous pourriez avoir d’autres droits prévus par les lois de votre pays. Le présent contrat ne modifie pas les droits que vous confèrent les lois de votre pays si celles-ci ne le permettent pas.


Empty file.
Empty file.
Empty file.
Empty file.
Binary file not shown.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions pili-sdk-csharp/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="8.0.1-beta1" targetFramework="net45" />
<package id="System.Net.Http" version="4.3.4" targetFramework="net45" />
</packages>
2 changes: 2 additions & 0 deletions pili-sdk-csharp/pili-sdk-csharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<Compile Include="example.cs" />
Expand All @@ -59,6 +60,7 @@
<Compile Include="pili\PiliException.cs" />
<Compile Include="pili\Stream.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="pili\Rtc.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
104 changes: 104 additions & 0 deletions pili-sdk-csharp/pili/Rtc.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using pili_sdk_csharp.pili_qiniu;
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using pili_sdk_csharp.pili_common;
namespace pili_sdk_csharp.rtc
{
public class RtcManager
{
private Credentials cre;
private async Task<HttpResponseMessage> Post(Uri url, string contentType, string body)
{
var content = new StringContent(body, Encoding.UTF8, contentType);
content.Headers.ContentType.CharSet = "";
HttpClient client = new HttpClient();
String token = cre.signRequest(url, "POST", body.GetBytes(Config.UTF8), contentType);
client.DefaultRequestHeaders.Add("Authorization", token);
var response = await client.PostAsync(url, content);
return response;
}

private async Task<HttpResponseMessage> Get(Uri url)
{

HttpClient client = new HttpClient();
String token = cre.signRequest(url, "GET", null, null);
client.DefaultRequestHeaders.Add("Authorization", token);
var response = await client.GetAsync(url);
return response;
}
private async Task<HttpResponseMessage> Delete(Uri url)
{

HttpClient client = new HttpClient();
String token = cre.signRequest(url, "DELETE", null, null);
client.DefaultRequestHeaders.Add("Authorization", token);
var response = await client.DeleteAsync(url);
return response;
}

public RtcManager(Credentials cre)
{
this.cre = cre;
}


public HttpResponseMessage createApp(String hub, String title, int maxUsers, bool noAutoKickUser)
{
Uri url = new Uri("http://rtc.qiniuapi.com/v3/apps");
JObject jObj = new JObject();
if (hub != null) jObj.Add("hub", hub);
if (title != null) jObj.Add("title", title);
if (hub != null) jObj.Add("maxUsers", maxUsers);
jObj.Add("noAutoKickUser", noAutoKickUser);

return Post(url, "application/json", jObj.ToString()).Result;

}

public HttpResponseMessage getApp(String appId)
{
Uri url = new Uri("http://rtc.qiniuapi.com/v3/apps/" + appId);
return Get(url).Result;
}

public HttpResponseMessage deleteApp(String appId)
{
Uri url = new Uri("http://rtc.qiniuapi.com/v3/apps/" + appId);
return Delete(url).Result;
}

public HttpResponseMessage updateApp(string appId, string hub, string title, int maxUsers, bool noAutoKickUser)
{
Uri url = new Uri("http://rtc.qiniuapi.com/v3/apps/" + appId);
JObject jObj = new JObject();
if (hub != null) jObj.Add("hub", hub);
if (title != null) jObj.Add("title", title);
if (hub != null) jObj.Add("maxUsers", maxUsers);
jObj.Add("noAutoKickUser", noAutoKickUser);

return Post(url, "application/json", jObj.ToString()).Result;
}

public HttpResponseMessage listUser(string appId, string roomName)
{
Uri url = new Uri(String.Format("http://rtc.qiniuapi.com/v3/apps/{0}/rooms/{1}/users", appId, roomName));
return Get(url).Result;
}

public HttpResponseMessage kickUser(string appId, string roomName, string userId)
{
Uri url = new Uri(String.Format("http://rtc.qiniuapi.com/v3/apps/{0}/rooms/{1}/users/{2}", appId, roomName, userId));
return Delete(url).Result;
}
public HttpResponseMessage listActiveRooms(String appId, String prefix, int offset, int limit)
{
Uri url = new Uri(String.Format("http://rtc.qiniuapi.com/v3/apps/{0}/rooms?prefix={1}&offset{2}&limit={3}", appId, prefix, offset, limit));
return Get(url).Result;
}

}
}