我正在开发一个应用,用户根据用户搜索条件获取人员列表。从列表中向用户呈现当前正在搜索组的用户列表。我希望允许用户向列表中的选定用户发送邀请,从而形成一个2到6个用户的组。我不确定在哪里或什么研究来实现这一目标。此外,一旦邀请被发送并且用户在一个组中,我希望他们具有与基本聊天功能进行通信的功能。
所以我想要的是一些关于R& D在我的应用程序上提供此功能的建议。该应用程序将由托管的MySQL数据库支持。
修改
为了澄清一点,这是我在应用程序中描绘的基本流程
用户会看到一个用户列表,每个列表项都有一个邀请按钮
用户点击邀请按钮
点击的用户会收到邀请通知,并允许接受拒绝
如果ACCEPT将用户放入将存储在服务器上的组
其他用户可以加入群组
该群组中的用户可以邀请其他用户加入现有群组
群组中的所有用户都可以通过私人聊天与群组进行通信。
我只需要知道如何发送邀请以及接受或拒绝邀请开始。使用什么技术?
答案 0 :(得分:0)
我认为你必须建立一个后端服务。 One Way可能是使用Node JS构建Rest Api。您可以定义带有用户ID和组ID的邀请用户等路线。在路径功能中,您可以将组ID添加到用户ID后面的用户的邀请中。另一条路线可以是接受邀请,您可以在其中发送用户ID和组ID。在该功能中,您可以检查用户是否有该组的邀请,以及他是否已将他添加到组中。但这只是近千种可能方式的建议。您还可以在应用程序旁边添加这些功能。而不是使用我上面提到的函数api路由只是直接在应用程序中。但是,如果数据库中有新的邀请记录,则必须通知用户推送通知。但我建议建立一个小服务器。
可以在这里看一下基本的休息msql node js tutorial https://codeforgeek.com/2015/01/nodejs-mysql-tutorial/你会在这里定义一个像
这样的路由function inviteUser(req,res) {
pool.getConnection(function(err,connection){
if (err) {
connection.release();
res.json({"code" : 100, "status" : "Error in connection database"});
return;
}
console.log('connected as id ' + connection.threadId);
connection.query("select req.body.userId from user",function(err,rows){
connection.release();
if(!err) {
//ADD Group id to the user access the id with req.body.groupId
res.json(rows);
}
});
connection.on('error', function(err) {
res.json({"code" : 100, "status" : "Error in connection database"});
return;
});
});
}
function acceptInvitation(req,res){
pool.getConnection(function(err,connection){
if (err) {
connection.release();
res.json({"code" : 100, "status" : "Error in connection database"});
return;
}
console.log('connected as id ' + connection.threadId);
connection.query("select req.body.groupId from groups",function(err,rows){
connection.release();
if(!err) {
//ADD user id to the group access the id with req.body.userId
res.json(rows);
}
});
connection.on('error', function(err) {
res.json({"code" : 100, "status" : "Error in connection database"});
return;
});
});
}
}
app.get("/users/invite",function(req,res){-
inviteUser(req,res);
});
app.get("/users/accept",function(req,res){-
acceptInvitation(req,res);
});
在应用中,您将在服务器网址上发送http请求,例如http://localhost:8080/users/invite,主体为{userId:xxxxx,groupId:xxxxx}