当前位置: 首页>>代码示例>>C#>>正文


C# Response.AddContent方法代码示例

本文整理汇总了C#中Response.AddContent方法的典型用法代码示例。如果您正苦于以下问题:C# Response.AddContent方法的具体用法?C# Response.AddContent怎么用?C# Response.AddContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Response的用法示例。


在下文中一共展示了Response.AddContent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendKey

 private void SendKey(Transceiver connection, User request, string userPluginHash)
 {
     string publickey;
     string username;
     Message message = new Message();
     message.creator_plugin_hash = this._hash_code;
     message.type = Message.Type.ServerToUser;
     if(request == null)
     {
         publickey = this._server_public_key;
         username = "server";
     }
     else
     {
         publickey = (string)this._user_keys[request.connection];
         username = request.username;
     }
     Response content = new Response();
     message.content = content;
     content.type = BasicContent.Type.Response;
     content.rtype = "success";
     content.AddContent("command", "publickey");
     content.AddContent("username", username);
     content.AddContent("publickey", publickey);
     string mess = message.DumpMessage();
     connection.Write(mess);
 }
开发者ID:spox,项目名称:irisim,代码行数:27,代码来源:CryptManager.cs

示例2: UserInformation

 private void UserInformation(string username, Message message)
 {
     User userinfo = this.GetUser(username);
     Message response = new Message();
     response.type = Message.Type.ServerToUserPlugin;
     response.creator_plugin_hash = this._hash_code;
     response.destination_plugin_hash = message.creator_plugin_hash;
     Response content = new Response();
     content.rtype = "success";
     content.AddContent("command", "information");
     content.AddContent("username", userinfo.username);
     content.AddContent("alias", userinfo.alias);
     response.content = content;
     message.origin.Write(response);
     User requesterInfo = this.GetUser(message.origin);
     Message information = new Message();
     information.type = Message.Type.ServerToUser;
     information.creator_plugin_hash = this._hash_code;
     Information con = new Information();
     con.AddContent("username", requesterInfo.username);
     con.AddContent("alias", requesterInfo.alias);
     information.content = con;
     userinfo.connection.Write(information);
 }
开发者ID:spox,项目名称:irisim,代码行数:24,代码来源:UserManager.cs

示例3: ProcessCommand

 private void ProcessCommand(Message message, Command command)
 {
     try
     {
         switch(command.ctype)
         {
             case "login":
                 this.Login(command.GetContent("username"), command.GetContent("password"), message);
                 break;
             case "logout":
                 this.Logout(command.GetContent("username"), message);
                 break;
             case "register":
                 this.Register(command.GetContent("username"), command.GetContent("password"), command.GetContent("alias"));
                 break;
             case "status":
                 this.Status(command.GetContent("username"), message);
                 throw new Exception("Punching out so we don't send an error.");
                 break;
             case "information":
                 this.UserInformation(command.GetContent("username"), message);
                 break;
             default:
                 throw new UnknownType("Command not valid.");
                 break;
         }
     }
     catch(IrisIMException e)
     {
         Message resp = new Message();
         resp.creator_plugin_hash = this._hash_code;
         resp.destination_plugin_hash = message.creator_plugin_hash;
         resp.type = Message.Type.ServerToUserPlugin;
         Response content = new Response();
         content.rtype = "failure";
         content.AddContent("command", command.ctype);
         content.AddContent("reason", e.Message);
         resp.content = content;
         message.origin.Write(resp);
     }
     catch(Exception e)
     {
         Message resp = new Message();
         resp.creator_plugin_hash = this._hash_code;
         resp.destination_plugin_hash = message.creator_plugin_hash;
         resp.type = Message.Type.ServerToUserPlugin;
         Response content = new Response();
         content.rtype = "failure";
         content.AddContent("command", command.ctype);
         content.AddContent("reason", e.Message);
         resp.content = content;
         message.origin.Write(resp);
         Logger.log("UserManager ProcessCommand error:", Logger.Verbosity.moderate);
         Logger.log(e.Message+"\n"+e.StackTrace, Logger.Verbosity.moderate);
     }
 }
开发者ID:spox,项目名称:irisim,代码行数:56,代码来源:UserManager.cs

示例4: Status

 private void Status(string username, Message message)
 {
     User info = this._users.Get(username);
     string stats = info.GetStatus();
     Message statusMessage = new Message();
     statusMessage.type = Message.Type.ServerToUserPlugin;
     statusMessage.creator_plugin_hash = this._hash_code;
     statusMessage.destination_plugin_hash = message.creator_plugin_hash;
     Command command = (Command)message.content;
     Response contents = new Response();
     contents.AddContent(command.ctype, stats);
     statusMessage.content = contents;
     message.origin.Write(statusMessage);
 }
开发者ID:spox,项目名称:irisim,代码行数:14,代码来源:UserManager.cs

示例5: Login

 private void Login(string username, string password, Message message)
 {
     Logger.log("attempting login.", Logger.Verbosity.moderate);
     try
     {
         UserInfo info = this._user_database.GetUser(username, password);
         User user = new User(info.username, info.alias, message.origin);
         this._users.Add(user);
         Message response = new Message();
         response.type = Message.Type.ServerToUserPlugin;
         response.creator_plugin_hash = this._hash_code;
         response.destination_plugin_hash = message.creator_plugin_hash;
         Response content = new Response();
         content.rtype = "success";
         content.AddContent("command", "login");
         response.content = content;
         message.origin.Write(response);
     }
     catch(IrisIMException e)
     {
         throw new ItemNotFound("Invalid username/password");
     }
 }
开发者ID:spox,项目名称:irisim,代码行数:23,代码来源:UserManager.cs


注:本文中的Response.AddContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。